From: Jani Nikula <jani@nikula.org>
To: notmuch@notmuchmail.org
Subject: [PATCH 1/3] cli: add support for parsing multiple keyword arguments
Date: Sat, 6 Sep 2014 15:53:28 +0300 [thread overview]
Message-ID: <1410008010-3770-1-git-send-email-jani@nikula.org> (raw)
This allows having multiple --foo=bar --foo=baz options on the command
line, with the corresponding values OR'd together.
---
command-line-arguments.c | 6 +++++-
command-line-arguments.h | 1 +
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/command-line-arguments.c b/command-line-arguments.c
index 844d6c3d18bf..c6f7269603cb 100644
--- a/command-line-arguments.c
+++ b/command-line-arguments.c
@@ -23,7 +23,10 @@ _process_keyword_arg (const notmuch_opt_desc_t *arg_desc, char next, const char
while (keywords->name) {
if (strcmp (arg_str, keywords->name) == 0) {
if (arg_desc->output_var) {
- *((int *)arg_desc->output_var) = keywords->value;
+ if (arg_desc->opt_type == NOTMUCH_OPT_KEYWORD_FLAGS)
+ *((int *)arg_desc->output_var) |= keywords->value;
+ else
+ *((int *)arg_desc->output_var) = keywords->value;
}
return TRUE;
}
@@ -152,6 +155,7 @@ parse_option (const char *arg,
switch (try->opt_type) {
case NOTMUCH_OPT_KEYWORD:
+ case NOTMUCH_OPT_KEYWORD_FLAGS:
return _process_keyword_arg (try, next, value);
case NOTMUCH_OPT_BOOLEAN:
return _process_boolean_arg (try, next, value);
diff --git a/command-line-arguments.h b/command-line-arguments.h
index de1734ad2fdb..085a4923b5fa 100644
--- a/command-line-arguments.h
+++ b/command-line-arguments.h
@@ -8,6 +8,7 @@ enum notmuch_opt_type {
NOTMUCH_OPT_BOOLEAN, /* --verbose */
NOTMUCH_OPT_INT, /* --frob=8 */
NOTMUCH_OPT_KEYWORD, /* --format=raw|json|text */
+ NOTMUCH_OPT_KEYWORD_FLAGS, /* the above with values OR'd together */
NOTMUCH_OPT_STRING, /* --file=/tmp/gnarf.txt */
NOTMUCH_OPT_POSITION /* notmuch dump pos_arg */
};
--
2.1.0
next reply other threads:[~2014-09-06 12:53 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-06 12:53 Jani Nikula [this message]
2014-09-06 12:53 ` [PATCH 2/3] cli: add --output=address-{from, to, all} to notmuch search Jani Nikula
2014-09-06 13:35 ` Mark Walters
2014-09-06 16:41 ` [PATCH] cli: add --output=address-{from,to,all} " Jani Nikula
2014-09-06 16:47 ` [PATCH] cli: add --output=address-{from, to, all} " Jani Nikula
2014-09-06 17:47 ` Mark Walters
2014-09-19 19:57 ` [PATCH] cli: add --output=address-{from,to,all} " David Bremner
2014-09-20 8:04 ` [PATCH] cli: add --output=address-{from, to, all} " Michal Sojka
2014-09-06 12:53 ` [PATCH 3/3] cli: deduplicate addresses for --output=address-* Jani Nikula
2014-09-19 19:27 ` [PATCH 1/3] cli: add support for parsing multiple keyword arguments David Bremner
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=1410008010-3770-1-git-send-email-jani@nikula.org \
--to=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).