From: Michal Sojka Date: Sun, 2 Nov 2014 00:49:55 +0000 (+0100) Subject: [PATCH 05/10] cli: add support for hierarchical command line option arrays X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=e2f75d727f0342dab4c5c7107929b6a7eb5942ae;p=notmuch-archives.git [PATCH 05/10] cli: add support for hierarchical command line option arrays --- diff --git a/15/0be894d308652488c0eaacb8e787272069584b b/15/0be894d308652488c0eaacb8e787272069584b new file mode 100644 index 000000000..20e3d4124 --- /dev/null +++ b/15/0be894d308652488c0eaacb8e787272069584b @@ -0,0 +1,109 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by olra.theworths.org (Postfix) with ESMTP id 68CA5429E48 + for ; Sat, 1 Nov 2014 17:50:38 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: -2.3 +X-Spam-Level: +X-Spam-Status: No, score=-2.3 tagged_above=-999 required=5 + tests=[RCVD_IN_DNSWL_MED=-2.3] autolearn=disabled +Received: from olra.theworths.org ([127.0.0.1]) + by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id xIq6h8nMMv6n for ; + Sat, 1 Nov 2014 17:50:32 -0700 (PDT) +Received: from max.feld.cvut.cz (max.feld.cvut.cz [147.32.192.36]) + by olra.theworths.org (Postfix) with ESMTP id A0FE9431E64 + for ; Sat, 1 Nov 2014 17:50:15 -0700 (PDT) +Received: from localhost (unknown [192.168.200.7]) + by max.feld.cvut.cz (Postfix) with ESMTP id 0CA2B5CD287; + Sun, 2 Nov 2014 01:50:15 +0100 (CET) +X-Virus-Scanned: IMAP STYX AMAVIS +Received: from max.feld.cvut.cz ([192.168.200.1]) + by localhost (styx.feld.cvut.cz [192.168.200.7]) (amavisd-new, + port 10044) + with ESMTP id o_krpALX-RRe; Sun, 2 Nov 2014 01:50:10 +0100 (CET) +Received: from imap.feld.cvut.cz (imap.feld.cvut.cz [147.32.192.34]) + by max.feld.cvut.cz (Postfix) with ESMTP id 6E55E5CD294; + Sun, 2 Nov 2014 01:50:07 +0100 (CET) +Received: from wsh by steelpick.2x.cz with local (Exim 4.84) + (envelope-from ) + id 1XkjMq-000856-Gh; Sun, 02 Nov 2014 01:50:04 +0100 +From: Michal Sojka +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 +Message-Id: <1414889400-30977-6-git-send-email-sojkam1@fel.cvut.cz> +X-Mailer: git-send-email 2.1.1 +In-Reply-To: <1414889400-30977-1-git-send-email-sojkam1@fel.cvut.cz> +References: <1414889400-30977-1-git-send-email-sojkam1@fel.cvut.cz> +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.13 +Precedence: list +List-Id: "Use and development of the notmuch mail system." + +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +X-List-Received-Date: Sun, 02 Nov 2014 00:50:38 -0000 + +From: Jani Nikula + +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 +