[PATCH v3 06/10] cli: Introduce "notmuch address" command

Tomi Ollila tomi.ollila at iki.fi
Wed Nov 5 12:49:29 PST 2014


On Wed, Nov 05 2014, Michal Sojka <sojkam1 at fel.cvut.cz> wrote:

> This moves address-related functionality from search command to the
> new address command. The implementation shares almost all code and
> some command line options.
>
> Options --offset and --limit were intentionally not included in the
> address command, because they refer to messages numbers, which users
> do not see in the output. This could confuse users because, for
> example, they could see more addresses in the output that what was
> specified with --limit. This functionality can be correctly
> reimplemented for address subcommand later.
>
> Also useless values of --exclude flag were not included in the address
> command.
>
> This was inspired by a patch from Jani Nikula.
> ---
>  completion/notmuch-completion.bash | 42 ++++++++++++++++-
>  completion/notmuch-completion.zsh  | 10 +++-
>  doc/man1/notmuch-address.rst       | 89 ++++++++++++++++++++++++++++++++++++
>  doc/man1/notmuch-search.rst        | 20 +-------
>  doc/man1/notmuch.rst               |  7 +--
>  notmuch-client.h                   |  3 ++
>  notmuch-search.c                   | 93 +++++++++++++++++++++++++++-----------
>  notmuch.c                          |  2 +
>  8 files changed, 216 insertions(+), 50 deletions(-)
>  create mode 100644 doc/man1/notmuch-address.rst
>
> [ nnn lines removed ]
>
> +
> +int
> +notmuch_address_command (notmuch_config_t *config, int argc, char *argv[])
> +{
> +    search_context_t *ctx = &search_context;
> +    int opt_index, ret;
> +
> +    notmuch_opt_desc_t options[] = {
> +	{ NOTMUCH_OPT_KEYWORD_FLAGS, &ctx->output, "output", 'o',
> +	  (notmuch_keyword_t []){ { "sender", OUTPUT_SENDER },
> +				  { "recipients", OUTPUT_RECIPIENTS },
> +				  { 0, 0 } } },
> +	{ NOTMUCH_OPT_KEYWORD, &ctx->exclude, "exclude", 'x',
> +	  (notmuch_keyword_t []){ { "true", NOTMUCH_EXCLUDE_TRUE },
> +				  { "false", NOTMUCH_EXCLUDE_FALSE },
> +				  { 0, 0 } } },
> +	{ NOTMUCH_OPT_INHERIT, &common_options, NULL, 0, 0 },
> +	{ 0, 0, 0, 0, 0 }
> +    };
> +
> +    opt_index = parse_arguments (argc, argv, options, 1);
> +    if (opt_index < 0)
> +	return EXIT_FAILURE;
> +
> +    if (! ctx->output)
> +	ctx->output = OUTPUT_SENDER | OUTPUT_RECIPIENTS;

If no --output options are given, the default could be just
to OUTPUT_SENDER (for the speed and as this behaviour is not documented) 

(this can be also addressed in later patch, provided that this
functionality gets more "votes" from the community)

Tomi

> +
> +    if (_notmuch_search_prepare (ctx, config,
> +				 argc - opt_index, argv + opt_index))
> +	return EXIT_FAILURE;
> +
> +    ret = do_search_messages (ctx);
> +
> +    _notmuch_search_cleanup (ctx);
> +
> +    return ret ? EXIT_FAILURE : EXIT_SUCCESS;
> +}


More information about the notmuch mailing list