]> git.cworth.org Git - notmuch/commit
cli: add support for --no- prefixed boolean and keyword flag arguments
authorJani Nikula <jani@nikula.org>
Sat, 14 Oct 2017 13:16:06 +0000 (16:16 +0300)
committerDavid Bremner <david@tethera.net>
Wed, 13 Dec 2017 12:21:13 +0000 (08:21 -0400)
commit39abd3b5226fef99de1adaa2e8f6b1ba8480c5f5
tree7298aeae1f2903d556f5d74b7a6e186a959fd902
parent1c2de79a1d7f9990a5544e2ec0963a6cdf90d874
cli: add support for --no- prefixed boolean and keyword flag arguments

Add transparent support for negating boolean and keyword flag
arguments using --no-argument style on the command line. That is, if
the option description contains a boolean or a keyword flag argument
named "argument", --no-argument will match and negate it.

For boolean arguments this obviously means the logical NOT. For
keyword flag arguments this means bitwise AND of the bitwise NOT,
i.e. masking out the specified bits instead of OR'ing them in.

For example, you can use --no-exclude instead of --exclude=false in
notmuch show. If we had keyword flag arguments with some flags
defaulting to on, say --include=tags in notmuch dump/restore, this
would allow --no-include=tags to switch that off while not affecting
other flags.

As a curiosity, you should be able to warp your brain using
--no-exclude=true meaning false and --no-exclude=false meaning true if
you wish.

Specifying both "argument" and "no-argument" style arguments in the
same option description should be avoided. In this case, --no-argument
would match whichever is specified first, and --argument would only
match "argument".
command-line-arguments.c