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 D0735429E28 for ; Sun, 13 Nov 2011 08:58:50 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -0.7 X-Spam-Level: X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5 tests=[RCVD_IN_DNSWL_LOW=-0.7] 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 gE5LayXdop+7 for ; Sun, 13 Nov 2011 08:58:48 -0800 (PST) Received: from dmz-mailsec-scanner-5.mit.edu (DMZ-MAILSEC-SCANNER-5.MIT.EDU [18.7.68.34]) by olra.theworths.org (Postfix) with ESMTP id 6185C431FB6 for ; Sun, 13 Nov 2011 08:58:48 -0800 (PST) X-AuditID: 12074422-b7ff56d00000092f-74-4ebff7470902 Received: from mailhub-auth-1.mit.edu ( [18.9.21.35]) by dmz-mailsec-scanner-5.mit.edu (Symantec Messaging Gateway) with SMTP id F6.EB.02351.747FFBE4; Sun, 13 Nov 2011 11:58:47 -0500 (EST) Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103]) by mailhub-auth-1.mit.edu (8.13.8/8.9.2) with ESMTP id pADGwj0O013047; Sun, 13 Nov 2011 11:58:46 -0500 Received: from awakening.csail.mit.edu (awakening.csail.mit.edu [18.26.4.91]) (authenticated bits=0) (User authenticated as amdragon@ATHENA.MIT.EDU) by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id pADGwiIM020036 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT); Sun, 13 Nov 2011 11:58:45 -0500 (EST) Received: from amthrax by awakening.csail.mit.edu with local (Exim 4.77) (envelope-from ) id 1RPdQW-0001dK-F0; Sun, 13 Nov 2011 12:01:04 -0500 From: Austin Clements To: Jani Nikula , notmuch@notmuchmail.org Subject: Re: [PATCH v4 4/6] cli: add support for --output parameter in notmuch count In-Reply-To: References: User-Agent: Notmuch/0.9+29~g81d35f0 (http://notmuchmail.org) Emacs/23.3.1 (i486-pc-linux-gnu) Date: Sun, 13 Nov 2011 12:01:04 -0500 Message-ID: <87bosgufcf.fsf@awakening.csail.mit.edu> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprAKsWRmVeSWpSXmKPExsUixCmqrOv+fb+fwZUX5ha9exezWdxo7Wa0 +N9cbdE03dlizz4vi+s3ZzI7sHncPc3lManrGZPHrfuv2T2erbrF7DFp7UkWjy2H3jMHsEVx 2aSk5mSWpRbp2yVwZVxa/4K94LNsxednG5kbGF+LdTFyckgImEjMXL2XHcIWk7hwbz1bFyMX h5DAPkaJ0++mskA4Gxgl/v19zQrhnGSSuLVqFlRmCaNE36HXYP1sAhoS2/YvZwSxRQSsJM49 fA1UxMHBLFAh0XQ5FiQsLBAisWTjSrByToEwiR3tG5hAbCGBGolnfz+A2aICsRJHryxjBGll EVCV2NUUAhLmBbp0zt9ZTBC2oMTJmU9YQGxmAS2JG/9eMk1gFJyFJDULSWoBI9MqRtmU3Crd 3MTMnOLUZN3i5MS8vNQiXVO93MwSvdSU0k2MoIBnd1HawfjzoNIhRgEORiUeXgfp/X5CrIll xZW5hxglOZiURHkvfAYK8SXlp1RmJBZnxBeV5qQWH2KU4GBWEuGtXAGU401JrKxKLcqHSUlz sCiJ83LtdPATEkhPLEnNTk0tSC2CycpwcChJ8O5/CdQoWJSanlqRlplTgpBm4uAEGc4DNFz/ Fcjw4oLE3OLMdIj8KUZFKXHeym9ACQGQREZpHlwvLCG9YhQHekWYNxOkigeYzOC6XwENZgIa zKKwF2RwSSJCSqqBUc/v/dG+hLe+rME/xf45BYr2b0zZvWkdm3V++oIWi6yWHxafnDZVpK47 l+5lWXAkr83w6bykOOE9vaJH6+bkWc552nVm+ctWju0N7KwzlYsav86ds8xyjnNZ+d6e+8xF jVU2lc4TJLqyqs+wHQ6WYTa77nHtGA/jOq72Cam5CvsmFc2YzxCpxFKckWioxVxUnAgAOUmI xiMDAAA= 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: Sun, 13 Nov 2011 16:58:51 -0000 Code looks good. Maybe put messages before threads in the documentation (both in the | list and in the descriptions), since that's the default? The output documentation for search does that. "--output" is an unfortunate name for this option since the *output* of count is always a count, but this seems necessary for consistency. On Sun, 6 Nov 2011 23:47:13 +0200, Jani Nikula wrote: > Add support for --output=messages (which remains the default) and > --output=threads to notmuch count. > > Signed-off-by: Jani Nikula > --- > NEWS | 5 +++++ > notmuch-count.c | 18 ++++++++++++++++-- > notmuch.1 | 29 +++++++++++++++++++++++++---- > 3 files changed, 46 insertions(+), 6 deletions(-) > > diff --git a/NEWS b/NEWS > index bfdba7b..009811f 100644 > --- a/NEWS > +++ b/NEWS > @@ -28,6 +28,11 @@ Add "notmuch search" --first and --maxitems options > The search command now takes options --first=[-]N and --maxitems=N to limit > the number of results shown. > > +Add "notmuch count --output" option > + > + The count command is now capable of counting threads in addition to > + messages. This is selected using the new --output=(threads|messages) option. > + > Notmuch 0.9 (2011-10-01) > ======================== > > diff --git a/notmuch-count.c b/notmuch-count.c > index a35be40..20ce334 100644 > --- a/notmuch-count.c > +++ b/notmuch-count.c > @@ -29,6 +29,7 @@ notmuch_count_command (void *ctx, int argc, char *argv[]) > notmuch_query_t *query; > char *query_str; > int i; > + notmuch_bool_t output_messages = TRUE; > > argc--; argv++; /* skip subcommand argument */ > > @@ -37,7 +38,17 @@ notmuch_count_command (void *ctx, int argc, char *argv[]) > i++; > break; > } > - { > + if (STRNCMP_LITERAL (argv[i], "--output=") == 0) { > + const char *opt = argv[i] + sizeof ("--output=") - 1; > + if (strcmp (opt, "threads") == 0) { > + output_messages = FALSE; > + } else if (strcmp (opt, "messages") == 0) { > + output_messages = TRUE; > + } else { > + fprintf (stderr, "Invalid value for --output: %s\n", opt); > + return 1; > + } > + } else { > fprintf (stderr, "Unrecognized option: %s\n", argv[i]); > return 1; > } > @@ -71,7 +82,10 @@ notmuch_count_command (void *ctx, int argc, char *argv[]) > return 1; > } > > - printf ("%u\n", notmuch_query_count_messages(query)); > + if (output_messages) > + printf ("%u\n", notmuch_query_count_messages (query)); > + else > + printf ("%u\n", notmuch_query_count_threads (query)); > > notmuch_query_destroy (query); > notmuch_database_close (notmuch); > diff --git a/notmuch.1 b/notmuch.1 > index c97334c..f53c183 100644 > --- a/notmuch.1 > +++ b/notmuch.1 > @@ -374,14 +374,35 @@ section below for details of the supported syntax for . > .RE > .RS 4 > .TP 4 > -.BR count " ..." > +.BR count " [options...] ..." > > Count messages matching the search terms. > > -The number of matching messages is output to stdout. > +The number of matching messages (or threads) is output to stdout. > > -With no search terms, a count of all messages in the database will be > -displayed. > +With no search terms, a count of all messages (or threads) in the database will > +be displayed. > + > +Supported options for > +.B count > +include > +.RS 4 > +.TP 4 > +.B \-\-output=(threads|messages) > + > +.RS 4 > +.TP 4 > +.B threads > + > +Output the number of matching threads. > +.RE > +.RS 4 > +.TP 4 > +.B messages > + > +Output the number of matching messages. This is the default. > +.RE > +.RE > .RE > .RE > > -- > 1.7.5.4 >