[PATCH v5 1/5] cli: command line parsing: allow default for keyword options
Peter Wang
novalazy at gmail.com
Sat May 26 19:32:53 PDT 2012
On Sat, 26 May 2012 16:54:50 +0100, Mark Walters <markwalters1009 at gmail.com> wrote:
> This changes the parsing for "keyword" options so that if the option
> is specified with no argument the first possible argument is
> chosen. This make it easier to add options to existing boolean
> arguments (the existing --option can default to TRUE).
This has the side-effect of allowing defaults for all keyword options,
right? I'm not sure that's desirable when the default is non-obvious.
Maybe keyword options which allow an optional argument should have an
explicit entry in the notmuch_keyword_t[] array, e.g. under "" or "default".
> diff --git a/command-line-arguments.c b/command-line-arguments.c
> index 76b185f..d40c7e6 100644
> --- a/command-line-arguments.c
> +++ b/command-line-arguments.c
> @@ -11,10 +11,16 @@
> */
>
> static notmuch_bool_t
> -_process_keyword_arg (const notmuch_opt_desc_t *arg_desc, const char *arg_str) {
> +_process_keyword_arg (const notmuch_opt_desc_t *arg_desc, char next, const char *arg_str) {
>
> const notmuch_keyword_t *keywords = arg_desc->keywords;
>
> + if (next == 0) {
> +/* No keyword given so return first option as default */
> + *((int *)arg_desc->output_var) = keywords->value;
> + return TRUE;
> + }
Indentation.
Peter
More information about the notmuch
mailing list