]> Sergey Matveev's repositories - public-inbox.git/commitdiff
lei q: fix "-" shortcut for --stdin
authorEric Wong <e@80x24.org>
Sun, 28 Feb 2021 12:25:27 +0000 (18:25 +0600)
committerEric Wong <e@80x24.org>
Mon, 1 Mar 2021 05:52:04 +0000 (05:52 +0000)
Due to the way our option parser handles this special case, it
must be the first option spec.  This helps us document things
better, even, since many command accept either a pathname or
--stdin|-.

lib/PublicInbox/LEI.pm
t/lei-q-thread.t

index a2f8ffe73d735c736ff63314cbd8995f0a032d06..f5e42869e0103c711fddd03cf001b6092ff27635 100644 (file)
@@ -108,10 +108,11 @@ sub index_opt {
 # see lei__complete() and PublicInbox::LeiHelp
 # command => [ positional_args, 1-line description, Getopt::Long option spec ]
 our %CMD = ( # sorted in order of importance/use:
-'q' => [ '--stdin|SEARCH_TERMS...', 'search for messages matching terms', qw(
-       save-as=s output|mfolder|o=s format|f=s dedupe|d=s threads|t+ augment|a
+'q' => [ '--stdin|SEARCH_TERMS...', 'search for messages matching terms',
+       'stdin|', # /|\z/ must be first for lone dash
+       qw(save-as=s output|mfolder|o=s format|f=s dedupe|d=s threads|t+
        sort|s=s reverse|r offset=i remote! local! external! pretty
-       include|I=s@ exclude=s@ only=s@ jobs|j=s globoff|g stdin|
+       include|I=s@ exclude=s@ only=s@ jobs|j=s globoff|g augment|a
        import-remote! lock=s@
        alert=s@ mua=s no-torsocks torsocks=s verbose|v+ quiet|q C=s@),
        PublicInbox::LeiQuery::curl_opt(), opt_dash('limit|n=i', '[0-9]+') ],
index 66db28a9cb8b7270579313d67bcd8cdcfe6a174d..0ddf47a69fe12741a1b1ef320e63a567ea45394e 100644 (file)
@@ -21,7 +21,8 @@ test_lei(sub {
        $buf = PublicInbox::LeiToMail::eml2mboxrd($eml, { kw => ['draft'] });
        lei_ok([qw(import -F mboxrd -)], undef, { 0 => $buf, %$lei_opt });
 
-       lei_ok qw(q -t m:testmessage@example.com);
+       lei_ok([qw(q - -t)], undef,
+               { 0 => \'m:testmessage@example.com', %$lei_opt });
        $res = json_utf8->decode($lei_out);
        is(scalar(@$res), 3, 'got 2 results');
        pop @$res;