From: Eric Wong <e@80x24.org> To: meta@public-inbox.org Subject: [PATCH 02/17] lei: favor "keywords" over "flags", test --no-kw Date: Sat, 6 Feb 2021 12:18:29 +0000 Message-ID: <20210206121844.10979-3-e@80x24.org> (raw) In-Reply-To: <20210206121844.10979-1-e@80x24.org> JMAP brain says "keywords", IMAP brain says "flags"; JMAP brain wins today. Since "keywords" is a bit long, support "kw" as a shortcut since there's no conflict and "kw:" will be our search prefix for looking up messages by keyword. --- lib/PublicInbox/LEI.pm | 7 ++++--- lib/PublicInbox/LeiImport.pm | 4 ++-- t/lei.t | 21 ++++++++++++++++++++- 3 files changed, 26 insertions(+), 6 deletions(-) diff --git a/lib/PublicInbox/LEI.pm b/lib/PublicInbox/LEI.pm index 682d1bd1..b058b533 100644 --- a/lib/PublicInbox/LEI.pm +++ b/lib/PublicInbox/LEI.pm @@ -131,7 +131,7 @@ our %CMD = ( # sorted in order of importance/use: 'exclude mail matching From: or thread from non-Message-ID searches', qw(stdin| thread|t from|f=s mid=s oid=s) ], 'mark' => [ 'MESSAGE_FLAGS...', - 'set/unset flags on message(s) from stdin', + 'set/unset keywords on message(s) from stdin', qw(stdin| oid=s exact by-mid|mid:s) ], 'forget' => [ '[--stdin|--oid=OID|--by-mid=MID]', "exclude message(s) on stdin from `q' search results", @@ -152,7 +152,8 @@ our %CMD = ( # sorted in order of importance/use: 'add-watch' => [ '[URL_OR_PATHNAME]', 'watch for new messages and flag changes', - qw(import! flags! interval=s recursive|r exclude=s include=s) ], + qw(import! kw|keywords|flags! interval=s recursive|r + exclude=s include=s) ], 'ls-watch' => [ '[FILTER...]', 'list active watches with numbers and status', qw(format|f=s z) ], 'pause-watch' => [ '[WATCH_NUMBER_OR_FILTER]', qw(all local remote) ], @@ -163,7 +164,7 @@ our %CMD = ( # sorted in order of importance/use: 'import' => [ 'URLS_OR_PATHNAMES...|--stdin', 'one-time import/update from URL or filesystem', qw(stdin| offset=i recursive|r exclude=s include|I=s - format|f=s flags!), + format|f=s kw|keywords|flags!), ], 'config' => [ '[...]', sub { diff --git a/lib/PublicInbox/LeiImport.pm b/lib/PublicInbox/LeiImport.pm index 4a9af8a7..2c7cbf2b 100644 --- a/lib/PublicInbox/LeiImport.pm +++ b/lib/PublicInbox/LeiImport.pm @@ -26,7 +26,7 @@ sub call { # the main "lei import" method my ($cls, $lei, @argv) = @_; my $sto = $lei->_lei_store(1); $sto->write_prepare($lei); - $lei->{opt}->{flags} //= 1; + $lei->{opt}->{kw} //= 1; my $fmt = $lei->{opt}->{'format'}; my $self = $lei->{imp} = bless {}, $cls; return $lei->fail('--format unspecified') if !$fmt; @@ -63,7 +63,7 @@ sub ipc_atfork_child { sub _import_fh { my ($lei, $fh, $x) = @_; - my $set_kw = $lei->{opt}->{flags}; + my $set_kw = $lei->{opt}->{kw}; my $fmt = $lei->{opt}->{'format'}; eval { if ($fmt eq 'eml') { diff --git a/t/lei.t b/t/lei.t index eb824a30..41d854e8 100644 --- a/t/lei.t +++ b/t/lei.t @@ -400,7 +400,26 @@ my $test_import = sub { ok($lei->(qw(q s:boolean)), 'search hit after import'); ok($lei->(qw(import -f eml), 't/data/message_embed.eml'), 'import single file by path'); - $cleanup->(); + + my $str = <<''; +From: a@b +Message-ID: <x@y> +Status: RO + + ok($lei->([qw(import -f eml -)], undef, { %$opt, 0 => \$str }), + 'import single file with keywords from stdin'); + $lei->(qw(q m:x@y)); + my $res = $json->decode($out); + is($res->[1], undef, 'only one result'); + is_deeply($res->[0]->{kw}, ['seen'], "message `seen' keyword set"); + + $str =~ tr/x/v/; # v@y + ok($lei->([qw(import --no-kw -f eml -)], undef, { %$opt, 0 => \$str }), + 'import single file with --no-kw from stdin'); + $lei->(qw(q m:v@y)); + $res = $json->decode($out); + is($res->[1], undef, 'only one result'); + is_deeply($res->[0]->{kw}, [], 'no keywords set'); }; my $test_lei_common = sub {
next prev parent reply other threads:[~2021-02-06 12:18 UTC|newest] Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-02-06 12:18 [PATCH 00/17] lei: more random updates Eric Wong 2021-02-06 12:18 ` [PATCH 01/17] lei_overview: drop unnecessary autoflush call Eric Wong 2021-02-06 12:18 ` Eric Wong [this message] 2021-02-06 12:18 ` [PATCH 03/17] lei: fix completion of --no-kw / --no-keywords Eric Wong 2021-02-06 12:18 ` [PATCH 04/17] lei: abort lei_import worker on client abort Eric Wong 2021-02-06 12:18 ` [PATCH 05/17] init: lowercase -j for --jobs Eric Wong 2021-02-06 12:18 ` [PATCH 06/17] lei_query: trim curl options Eric Wong 2021-02-06 12:18 ` [PATCH 07/17] tests: add test_lei wrapper, split out t/lei-import.t Eric Wong 2021-02-06 12:18 ` [PATCH 08/17] t/lei-externals: split out into separate test Eric Wong 2021-02-06 12:18 ` [PATCH 09/17] t/tests: split out setup_public_inboxes sub Eric Wong 2021-02-06 12:18 ` [PATCH 10/17] tests: split out lei-daemon.t from lei.t Eric Wong 2021-02-06 12:18 ` [PATCH 11/17] treewide: replace confess with croak Eric Wong 2021-02-06 12:18 ` [PATCH 12/17] script/lei: avoid waitpid(-1, ...) to keep tests fast Eric Wong 2021-02-06 12:18 ` [PATCH 13/17] lei: add-external --mirror support Eric Wong 2021-02-06 12:18 ` [PATCH 14/17] lei help: split out into separate file Eric Wong 2021-02-06 12:18 ` [PATCH 15/17] lei add-external: reject index and remote opts w/o mirror Eric Wong 2021-02-06 12:18 ` [PATCH 16/17] lei_curl: replace -K/--config with --curl-config Eric Wong 2021-02-06 12:18 ` [PATCH 17/17] lei: remove short switch support for curl(1) options Eric Wong
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style List information: https://public-inbox.org/README * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20210206121844.10979-3-e@80x24.org \ --to=e@80x24.org \ --cc=meta@public-inbox.org \ --subject='Re: [PATCH 02/17] lei: favor "keywords" over "flags", test --no-kw' \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
user/dev discussion of public-inbox itself This inbox may be cloned and mirrored by anyone: git clone --mirror https://public-inbox.org/meta git clone --mirror http://czquwvybam4bgbro.onion/meta git clone --mirror http://hjrcffqmbrq6wope.onion/meta git clone --mirror http://ou63pmih66umazou.onion/meta # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V1 meta meta/ https://public-inbox.org/meta \ meta@public-inbox.org public-inbox-index meta Example config snippet for mirrors. Newsgroups are available over NNTP: nntp://news.public-inbox.org/inbox.comp.mail.public-inbox.meta nntp://ou63pmih66umazou.onion/inbox.comp.mail.public-inbox.meta nntp://czquwvybam4bgbro.onion/inbox.comp.mail.public-inbox.meta nntp://hjrcffqmbrq6wope.onion/inbox.comp.mail.public-inbox.meta nntp://news.gmane.io/gmane.mail.public-inbox.general note: .onion URLs require Tor: https://www.torproject.org/ code repositories for project(s) associated with this inbox: https://80x24.org/public-inbox.git AGPL code for this site: git clone https://public-inbox.org/public-inbox.git