From: Austin Clements <amdragon@MIT.EDU>
To: Jani Nikula <jani@nikula.org>, notmuch@notmuchmail.org
Subject: Re: [PATCH v4 4/6] cli: add support for --output parameter in notmuch count
Date: Sun, 13 Nov 2011 12:01:04 -0500 [thread overview]
Message-ID: <87bosgufcf.fsf@awakening.csail.mit.edu> (raw)
In-Reply-To: <f499964b78d509223c531f1c424e98ed821fd602.1320615322.git.jani@nikula.org>
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 <jani@nikula.org> wrote:
> Add support for --output=messages (which remains the default) and
> --output=threads to notmuch count.
>
> Signed-off-by: Jani Nikula <jani@nikula.org>
> ---
> 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 <search-terms>.
> .RE
> .RS 4
> .TP 4
> -.BR count " <search-term>..."
> +.BR count " [options...] <search-term>..."
>
> 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
>
next prev parent reply other threads:[~2011-11-13 16:58 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-11-06 21:47 [PATCH v4 0/6] lib/cli: limit number of messages in search results Jani Nikula
2011-11-06 21:47 ` [PATCH v4 1/6] lib: add function to get the number of threads matching a search Jani Nikula
2011-11-06 21:47 ` [PATCH v4 2/6] cli: add options --first and --maxitems to notmuch search Jani Nikula
2011-11-13 16:52 ` Austin Clements
2011-11-06 21:47 ` [PATCH v4 3/6] cli: drop unused code from notmuch count Jani Nikula
2011-11-06 21:47 ` [PATCH v4 4/6] cli: add support for --output parameter in " Jani Nikula
2011-11-13 17:01 ` Austin Clements [this message]
2011-11-06 21:47 ` [PATCH v4 5/6] test: add tests for " Jani Nikula
2011-11-06 21:47 ` [PATCH v4 6/6] test: add tests for notmuch search --first and --maxitems Jani Nikula
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://notmuchmail.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87bosgufcf.fsf@awakening.csail.mit.edu \
--to=amdragon@mit.edu \
--cc=jani@nikula.org \
--cc=notmuch@notmuchmail.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://yhetil.org/notmuch.git/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).