From: Mark Walters Date: Tue, 4 Nov 2014 09:08:16 +0000 (+0000) Subject: Re: [PATCH v2 07/10] cli: search: Convert --output to keyword argument X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=db6debad1928bd6914134fb1eebb3081b7484ce7;p=notmuch-archives.git Re: [PATCH v2 07/10] cli: search: Convert --output to keyword argument --- diff --git a/8d/7fbbed48560843285896be907a97c455fd8ed7 b/8d/7fbbed48560843285896be907a97c455fd8ed7 new file mode 100644 index 000000000..e89ac3eb9 --- /dev/null +++ b/8d/7fbbed48560843285896be907a97c455fd8ed7 @@ -0,0 +1,186 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by olra.theworths.org (Postfix) with ESMTP id 3A56B429E41 + for ; Tue, 4 Nov 2014 01:08:43 -0800 (PST) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: -1.098 +X-Spam-Level: +X-Spam-Status: No, score=-1.098 tagged_above=-999 required=5 + tests=[DKIM_ADSP_CUSTOM_MED=0.001, FREEMAIL_FROM=0.001, + NML_ADSP_CUSTOM_MED=1.2, RCVD_IN_DNSWL_MED=-2.3] autolearn=disabled +Received: from olra.theworths.org ([127.0.0.1]) + by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id z-lEPwolnr9s for ; + Tue, 4 Nov 2014 01:08:39 -0800 (PST) +Received: from mail2.qmul.ac.uk (mail2.qmul.ac.uk [138.37.6.6]) + (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id 04EB2429E37 + for ; Tue, 4 Nov 2014 01:08:39 -0800 (PST) +Received: from smtp.qmul.ac.uk ([138.37.6.40]) + by mail2.qmul.ac.uk with esmtp (Exim 4.71) + (envelope-from ) + id 1Xla65-0005qY-Eu; Tue, 04 Nov 2014 09:08:37 +0000 +Received: from 5751dfa2.skybroadband.com ([87.81.223.162] helo=localhost) + by smtp.qmul.ac.uk with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.71) + (envelope-from ) + id 1Xla64-0004J4-Vr; Tue, 04 Nov 2014 09:08:17 +0000 +From: Mark Walters +To: Michal Sojka , notmuch@notmuchmail.org +Subject: Re: [PATCH v2 07/10] cli: search: Convert --output to keyword + argument +In-Reply-To: <87389z4a1g.fsf@qmul.ac.uk> +References: <1415058622-21162-1-git-send-email-sojkam1@fel.cvut.cz> + <1415058622-21162-8-git-send-email-sojkam1@fel.cvut.cz> + <87389z4a1g.fsf@qmul.ac.uk> +User-Agent: Notmuch/0.18.1+86~gef5e66a (http://notmuchmail.org) Emacs/23.4.1 + (x86_64-pc-linux-gnu) +Date: Tue, 04 Nov 2014 09:08:16 +0000 +Message-ID: <87wq7b2v0f.fsf@qmul.ac.uk> +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Sender-Host-Address: 87.81.223.162 +X-QM-Geographic: According to ripencc, + this message was delivered by a machine in Britain (UK) (GB). +X-QM-SPAM-Info: Sender has good ham record. :) +X-QM-Body-MD5: f500e3addfb64b38de9f247ac468aa3b (of first 20000 bytes) +X-SpamAssassin-Score: -0.1 +X-SpamAssassin-SpamBar: / +X-SpamAssassin-Report: The QM spam filters have analysed this message to + determine if it is + spam. We require at least 5.0 points to mark a message as spam. + This message scored -0.1 points. + Summary of the scoring: + * 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail + provider * (markwalters1009[at]gmail.com) + * -0.1 AWL AWL: From: address is in the auto white-list +X-QM-Scan-Virus: ClamAV says the message is clean +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.13 +Precedence: list +List-Id: "Use and development of the notmuch mail system." + +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +X-List-Received-Date: Tue, 04 Nov 2014 09:08:43 -0000 + + +> Hi +> +> On Mon, 03 Nov 2014, Michal Sojka wrote: +>> Now, when address related outputs are in a separate command, it makes +>> no sense to combine multiple --output options in search command line. +>> Using switch statement to handle different outputs is more readable +>> than a series of if statements. +> +> I am not keen on this change: I think the user should always be able to +> force the default output by setting command line options (which should +> protect against future changes in the default). Thus I would like to +> continue to allow --output=sender --output=recipients. +> +> I do approve of making the default do something useful but whether it +> should be both or just sender (which is much faster) is unclear to me. + +Sorry my stupidity: you said "search" not "address" so this is fine. + +Best wishes + +Mark + +> +> Best wishes +> +> Mark +> +> +>> --- +>> doc/man1/notmuch-search.rst | 3 --- +>> notmuch-search.c | 25 +++++++++++++------------ +>> 2 files changed, 13 insertions(+), 15 deletions(-) +>> +>> diff --git a/doc/man1/notmuch-search.rst b/doc/man1/notmuch-search.rst +>> index 65df288..0cc2911 100644 +>> --- a/doc/man1/notmuch-search.rst +>> +++ b/doc/man1/notmuch-search.rst +>> @@ -78,9 +78,6 @@ Supported options for **search** include +>> by null characters (--format=text0), as a JSON array +>> (--format=json), or as an S-Expression list (--format=sexp). +>> +>> - This option can be given multiple times to combine different +>> - outputs. +>> - +>> ``--sort=``\ (**newest-first**\ \|\ **oldest-first**) +>> This option can be used to present results in either +>> chronological order (**oldest-first**) or reverse chronological +>> diff --git a/notmuch-search.c b/notmuch-search.c +>> index cbd84f5..402e860 100644 +>> --- a/notmuch-search.c +>> +++ b/notmuch-search.c +>> @@ -593,7 +593,7 @@ notmuch_search_command (notmuch_config_t *config, int argc, char *argv[]) +>> int opt_index, ret; +>> +>> notmuch_opt_desc_t options[] = { +>> - { NOTMUCH_OPT_KEYWORD_FLAGS, &ctx->output, "output", 'o', +>> + { NOTMUCH_OPT_KEYWORD, &ctx->output, "output", 'o', +>> (notmuch_keyword_t []){ { "summary", OUTPUT_SUMMARY }, +>> { "threads", OUTPUT_THREADS }, +>> { "messages", OUTPUT_MESSAGES }, +>> @@ -607,13 +607,11 @@ notmuch_search_command (notmuch_config_t *config, int argc, char *argv[]) +>> { 0, 0, 0, 0, 0 } +>> }; +>> +>> + ctx->output = OUTPUT_SUMMARY; +>> opt_index = parse_arguments (argc, argv, options, 1); +>> if (opt_index < 0) +>> return EXIT_FAILURE; +>> +>> - if (! ctx->output) +>> - ctx->output = OUTPUT_SUMMARY; +>> - +>> if (ctx->output != OUTPUT_FILES && ctx->output != OUTPUT_MESSAGES && +>> ctx->dupe != -1) { +>> fprintf (stderr, "Error: --duplicate=N is only supported with --output=files and --output=messages.\n"); +>> @@ -624,17 +622,20 @@ notmuch_search_command (notmuch_config_t *config, int argc, char *argv[]) +>> argc - opt_index, argv + opt_index)) +>> return EXIT_FAILURE; +>> +>> - if (ctx->output == OUTPUT_SUMMARY || +>> - ctx->output == OUTPUT_THREADS) +>> + switch (ctx->output) { +>> + case OUTPUT_SUMMARY: +>> + case OUTPUT_THREADS: +>> ret = do_search_threads (ctx); +>> - else if (ctx->output == OUTPUT_MESSAGES || +>> - ctx->output == OUTPUT_FILES) +>> + break; +>> + case OUTPUT_MESSAGES: +>> + case OUTPUT_FILES: +>> ret = do_search_messages (ctx); +>> - else if (ctx->output == OUTPUT_TAGS) +>> + break; +>> + case OUTPUT_TAGS: +>> ret = do_search_tags (ctx); +>> - else { +>> - fprintf (stderr, "Error: the combination of outputs is not supported.\n"); +>> - ret = 1; +>> + break; +>> + default: +>> + INTERNAL_ERROR ("Unexpected output"); +>> } +>> +>> _notmuch_search_cleanup (ctx); +>> -- +>> 2.1.1 +>> +>> _______________________________________________ +>> notmuch mailing list +>> notmuch@notmuchmail.org +>> http://notmuchmail.org/mailman/listinfo/notmuch