From: Michal Sojka <sojkam1@fel.cvut.cz>
To: notmuch@notmuchmail.org
Subject: [PATCH 05/10] cli: add support for hierarchical command line option arrays
Date: Sun, 2 Nov 2014 01:49:55 +0100 [thread overview]
Message-ID: <1414889400-30977-6-git-send-email-sojkam1@fel.cvut.cz> (raw)
In-Reply-To: <1414889400-30977-1-git-send-email-sojkam1@fel.cvut.cz>
From: Jani Nikula <jani@nikula.org>
NOTMUCH_OPT_INHERIT expects a notmuch_opt_desc_t * pointer in
output_var.
---
command-line-arguments.c | 14 ++++++++------
command-line-arguments.h | 1 +
2 files changed, 9 insertions(+), 6 deletions(-)
diff --git a/command-line-arguments.c b/command-line-arguments.c
index c6f7269..60a0138 100644
--- a/command-line-arguments.c
+++ b/command-line-arguments.c
@@ -122,16 +122,18 @@ parse_position_arg (const char *arg_str, int pos_arg_index,
*/
notmuch_bool_t
-parse_option (const char *arg,
- const notmuch_opt_desc_t *options) {
-
- assert(arg);
+parse_option (const char *_arg, const notmuch_opt_desc_t *options)
+{
+ assert(_arg);
assert(options);
- arg += 2;
-
+ const char *arg = _arg + 2; /* _arg starts with -- */
const notmuch_opt_desc_t *try;
for (try = options; try->opt_type != NOTMUCH_OPT_END; try++) {
+ if (try->opt_type == NOTMUCH_OPT_INHERIT &&
+ parse_option (_arg, try->output_var))
+ return TRUE;
+
if (! try->name)
continue;
diff --git a/command-line-arguments.h b/command-line-arguments.h
index 6444129..309aaf2 100644
--- a/command-line-arguments.h
+++ b/command-line-arguments.h
@@ -5,6 +5,7 @@
enum notmuch_opt_type {
NOTMUCH_OPT_END = 0,
+ NOTMUCH_OPT_INHERIT, /* another options table */
NOTMUCH_OPT_BOOLEAN, /* --verbose */
NOTMUCH_OPT_INT, /* --frob=8 */
NOTMUCH_OPT_KEYWORD, /* --format=raw|json|text */
--
2.1.1
next prev parent reply other threads:[~2014-11-02 0:50 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-02 0:49 [PATCH 00/10] "notmuch address" command Michal Sojka
2014-11-02 0:49 ` [PATCH 01/10] cli: search: Rename options to context Michal Sojka
2014-11-02 0:49 ` [PATCH 02/10] cli: search: Move more variables into search_context_t Michal Sojka
2014-11-02 0:49 ` [PATCH 03/10] cli: search: Convert ctx. to ctx-> Michal Sojka
2014-11-02 0:49 ` [PATCH 04/10] cli: search: Split notmuch_search_command to smaller functions Michal Sojka
2014-11-02 0:49 ` Michal Sojka [this message]
2014-11-02 0:49 ` [PATCH 06/10] cli: Introduce "notmuch address" command Michal Sojka
2014-11-02 0:49 ` [PATCH 07/10] cli: search: Convert --output to keyword argument Michal Sojka
2014-11-02 0:49 ` [PATCH 08/10] cli: address: Do not output duplicate addresses Michal Sojka
2014-11-02 0:49 ` [PATCH 09/10] cli: address: Add --output=count Michal Sojka
2014-11-02 0:50 ` [PATCH 10/10] cli: address: Add --filter-by option to configure address filtering Michal Sojka
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=1414889400-30977-6-git-send-email-sojkam1@fel.cvut.cz \
--to=sojkam1@fel.cvut.cz \
--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).