diff options
author | Eric Wong <e@80x24.org> | 2023-10-02 15:00:23 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2023-10-02 20:14:34 +0000 |
commit | 299aac294ec359a2f069e0e881ef82f55a101def (patch) | |
tree | 325945d0982d162e7a8b6d40e5161e051e5904ad /lib/PublicInbox/LEI.pm | |
parent | b8f767e7aecb1c5e54f6dcf60f90491cdfde0624 (diff) | |
download | public-inbox-299aac294ec359a2f069e0e881ef82f55a101def.tar.gz |
Calling vmd_mod_extract after optparse causes the implicit stdin-as-input functionality to fail, as the implicit stdin requires a lack of inputs remaining in argv after option parsing (along with a regular file or pipe as stdin). This allows commands such as `lei import -F eml +kw:seen' to work without `--stdin', `-' or any path names when importing a single message. This also ensures commands like `lei import +kw:seen' without any inputs/locations will fail reliably, as the extra +kw: arg won't be a false-positive.
Diffstat (limited to 'lib/PublicInbox/LEI.pm')
-rw-r--r-- | lib/PublicInbox/LEI.pm | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/lib/PublicInbox/LEI.pm b/lib/PublicInbox/LEI.pm index 06bc7ebd..817772f7 100644 --- a/lib/PublicInbox/LEI.pm +++ b/lib/PublicInbox/LEI.pm @@ -234,7 +234,7 @@ our %CMD = ( # sorted in order of importance/use: 'plonk' => [ '--threads|--from=IDENT', 'exclude mail matching From: or threads from non-Message-ID searches', qw(stdin| threads|t from|f=s mid=s oid=s), @c_opt ], -'tag' => [ 'KEYWORDS...', +'tag' => [ 'KEYWORDS... LOCATION...|--stdin', 'set/unset keywords and/or labels on message(s)', qw(stdin| in-format|F=s input|i=s@ oid=s@ mid=s@), @net_opt, @c_opt, pass_through('-kw:foo for delete') ], @@ -243,7 +243,8 @@ our %CMD = ( # sorted in order of importance/use: 'remove imported messages from IMAP, Maildirs, and MH', qw(exact! all jobs:i indexed), @c_opt ], -'add-watch' => [ 'LOCATION...', 'watch for new messages and flag changes', +'add-watch' => [ 'LOCATION... [LABELS...]', + 'watch for new messages and flag changes', qw(poll-interval=s state=s recursive|r), @c_opt ], 'rm-watch' => [ 'LOCATION...', 'remove specified watch(es)', qw(recursive|r), @c_opt ], @@ -260,7 +261,7 @@ our %CMD = ( # sorted in order of importance/use: qw(in-format|F=s kw! offset=i recursive|r exclude=s include|I=s verbose|v+ incremental!), @net_opt, # mainly for --proxy= @c_opt ], -'import' => [ 'LOCATION...|--stdin', +'import' => [ 'LOCATION...|--stdin [LABELS...]', 'one-time import/update from URL or filesystem', qw(stdin| offset=i recursive|r exclude=s include|I=s new-only lock=s@ in-format|F=s kw! verbose|v+ incremental! mail-sync!), @@ -711,6 +712,14 @@ sub optparse ($$$) { # "-" aliases "stdin" or "clear" $OPT->{$lone_dash} = ${$OPT->{$lone_dash}} if defined $lone_dash; + if ($proto =~ s/\s*\[?(?:KEYWORDS|LABELS)\.\.\.\]?\s*//g) { + require PublicInbox::LeiInput; + my @err = PublicInbox::LeiInput::vmd_mod_extract($self, $argv); + return $self->fail(join("\n", @err)) if @err; + } else { + warn "proto $proto\n" if $cmd =~ /(add-watch|tag|index)/; + } + my $i = 0; my $POS_ARG = '[A-Z][A-Z0-9_]+'; my ($err, $inf); @@ -741,8 +750,7 @@ sub optparse ($$$) { -f _) && -r _) { $OPT->{stdin} //= 1; } - $ok = defined($OPT->{$sw}); - last if $ok; + $ok = defined($OPT->{$sw}) and last; } elsif (defined($argv->[$i])) { $ok = 1; $i++; |