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 E2299431FB6 for ; Sat, 6 Sep 2014 05:53:42 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -0.7 X-Spam-Level: X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5 tests=[RCVD_IN_DNSWL_LOW=-0.7] 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 6AHgVXx+KsPM for ; Sat, 6 Sep 2014 05:53:37 -0700 (PDT) Received: from mail-wi0-f180.google.com (mail-wi0-f180.google.com [209.85.212.180]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id 30321431FBC for ; Sat, 6 Sep 2014 05:53:37 -0700 (PDT) Received: by mail-wi0-f180.google.com with SMTP id ex7so609183wid.13 for ; Sat, 06 Sep 2014 05:53:33 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=Uq5Jq31quR31nh5r9iX/mSJrDDNveWaNZkrAENfogdM=; b=BYt8xdHFG0K2ihWGCm9rKJxl8ynRl/naJYs+VcxxwT+HLjjsETOGM9LgSRBAXSCAfc GhJLqNR6am9hKCzndj3e9Hvos6fIBM+ekIqGpe0LERx8y8b78byFQicm2JvlaqtqYUc7 wJQRzTkJENHvhwv204uE+jEQkVmWL2L37/xK0AqnjhvYDm15kGDUOor9ICxaS52yQ1sl fX12ot3r616sEIPhIivdTw5F+6TkCvvio6bL2jlutAf0RQp/LTs6oswHc2nwVMN8ySmZ AHfrEW8WPZWheBpAph29ZP3TqUQAcPKqsUMYVFcbWbcwtn2CEpEVCVJsjDb7tSqjH7k3 omHw== X-Gm-Message-State: ALoCoQnTzIBYoH92qkTbeVPhT33deUAbLOtLA2rREar4BZiwY6hLL9/wvaxtPnGRw9GR6ESnOpxb X-Received: by 10.180.186.10 with SMTP id fg10mr9898874wic.20.1410008012430; Sat, 06 Sep 2014 05:53:32 -0700 (PDT) Received: from localhost (dsl-hkibrasgw2-58c374-75.dhcp.inet.fi. [88.195.116.75]) by mx.google.com with ESMTPSA id r8sm4483908wjy.20.2014.09.06.05.53.31 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 06 Sep 2014 05:53:31 -0700 (PDT) From: Jani Nikula 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 Message-Id: <1410008010-3770-1-git-send-email-jani@nikula.org> X-Mailer: git-send-email 2.1.0 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: Sat, 06 Sep 2014 12:53:43 -0000 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