From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id C67791F9FF for ; Sun, 28 Feb 2021 12:25:28 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 2/3] lei q: fix "-" shortcut for --stdin Date: Sun, 28 Feb 2021 18:25:27 +0600 Message-Id: <20210228122528.18552-3-e@80x24.org> In-Reply-To: <20210228122528.18552-1-e@80x24.org> References: <20210228122528.18552-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: 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 | 7 ++++--- t/lei-q-thread.t | 3 ++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/PublicInbox/LEI.pm b/lib/PublicInbox/LEI.pm index a2f8ffe7..f5e42869 100644 --- a/lib/PublicInbox/LEI.pm +++ b/lib/PublicInbox/LEI.pm @@ -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]+') ], diff --git a/t/lei-q-thread.t b/t/lei-q-thread.t index 66db28a9..0ddf47a6 100644 --- a/t/lei-q-thread.t +++ b/t/lei-q-thread.t @@ -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;