1 Return-Path: <jani@nikula.org>
\r
2 X-Original-To: notmuch@notmuchmail.org
\r
3 Delivered-To: notmuch@notmuchmail.org
\r
4 Received: from localhost (localhost [127.0.0.1])
\r
5 by olra.theworths.org (Postfix) with ESMTP id 92D5642114C
\r
6 for <notmuch@notmuchmail.org>; Sat, 31 Aug 2013 23:12:02 -0700 (PDT)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5
\r
12 tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled
\r
13 Received: from olra.theworths.org ([127.0.0.1])
\r
14 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
15 with ESMTP id as0yIQl0xuyV for <notmuch@notmuchmail.org>;
\r
16 Sat, 31 Aug 2013 23:11:55 -0700 (PDT)
\r
17 Received: from mail-ee0-f49.google.com (mail-ee0-f49.google.com
\r
18 [74.125.83.49]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client
\r
19 certificate requested) by olra.theworths.org (Postfix) with ESMTPS id
\r
20 9138B4092A1 for <notmuch@notmuchmail.org>; Sat, 31 Aug 2013 03:34:34 -0700
\r
22 Received: by mail-ee0-f49.google.com with SMTP id d41so1357926eek.22
\r
23 for <notmuch@notmuchmail.org>; Sat, 31 Aug 2013 03:34:33 -0700 (PDT)
\r
24 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
\r
25 d=1e100.net; s=20130820;
\r
26 h=x-gm-message-state:from:to:cc:subject:date:message-id;
\r
27 bh=9GgMlPzsIeZ0/remkd5X4LIyibKDBPYYIr/ucCmWp9k=;
\r
28 b=GH0V1OH0JcJUg7Y7OnYk91sZufBIHXu77wxe/7bZv/MmvlaGA2KEJbaquG36V+ffTd
\r
29 PtpezAVUNv+B0CdxiFASKi61OyoFiWmBGUvpNjGKM8Epu1SlLziSbBMTfnifvubeo3os
\r
30 B0qvu0NtQKHfS2082mCHLGf3cO5j0vT/jDW5I9MQvvUQ+GuTg0tmRZHhis2j3t+S3JdE
\r
31 IM6Hy63P6IW9YVobvXKv+Btt/QJ8zhFi+qLFWrz7QFPKUIZlUAdOGvOOx7MH3hOPd8CC
\r
32 4dJnCLoDmXxaDfzWm+gppvN8j6sAbUq/iVoyiRnf+GYG7cwot7SjlO/XBG4BDR+sbZwa
\r
35 ALoCoQl/J+RIln6oP4/RTHYXAj0KTvap2hAYeZvq4qksP/yenVfXVH13zFDcUx08csFsq88pS/pb
\r
36 X-Received: by 10.15.26.7 with SMTP id m7mr2355856eeu.56.1377945272020;
\r
37 Sat, 31 Aug 2013 03:34:32 -0700 (PDT)
\r
38 Received: from localhost (dsl-hkibrasgw2-58c36f-91.dhcp.inet.fi.
\r
40 by mx.google.com with ESMTPSA id r48sm4021354eev.14.1969.12.31.16.00.00
\r
41 (version=TLSv1.2 cipher=RC4-SHA bits=128/128);
\r
42 Sat, 31 Aug 2013 03:34:31 -0700 (PDT)
\r
43 From: Jani Nikula <jani@nikula.org>
\r
44 To: notmuch@notmuchmail.org
\r
45 Subject: [RFC PATCH 1/2] cli: add support for global options that get passed
\r
47 Date: Sat, 31 Aug 2013 13:34:30 +0300
\r
49 <08036456064699510ef832f0c6740d98d324d185.1377945239.git.jani@nikula.org>
\r
50 X-Mailer: git-send-email 1.7.10.4
\r
51 X-BeenThere: notmuch@notmuchmail.org
\r
52 X-Mailman-Version: 2.1.13
\r
54 List-Id: "Use and development of the notmuch mail system."
\r
55 <notmuch.notmuchmail.org>
\r
56 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
57 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
58 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
59 List-Post: <mailto:notmuch@notmuchmail.org>
\r
60 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
61 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
62 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
63 X-List-Received-Date: Sun, 01 Sep 2013 06:12:02 -0000
\r
65 This allows sub-commands to have access to global options.
\r
67 notmuch-client.h | 21 +++++++++++++++++++++
\r
68 notmuch-config.c | 29 +++++++++++++++++++++++++++++
\r
69 notmuch.c | 10 ++++++++++
\r
70 3 files changed, 60 insertions(+)
\r
72 diff --git a/notmuch-client.h b/notmuch-client.h
\r
73 index afb0ddf..5656426 100644
\r
74 --- a/notmuch-client.h
\r
75 +++ b/notmuch-client.h
\r
76 @@ -320,6 +320,27 @@ notmuch_config_set_search_exclude_tags (notmuch_config_t *config,
\r
80 +/* global options */
\r
81 +typedef struct _notmuch_global_options {
\r
82 + notmuch_bool_t debug;
\r
83 + notmuch_bool_t verbose;
\r
84 + notmuch_bool_t no_hooks;
\r
85 +} notmuch_global_options_t;
\r
88 +notmuch_global_set (notmuch_config_t *config,
\r
89 + const notmuch_global_options_t *global_options);
\r
92 +notmuch_global_get_debug (notmuch_config_t *config);
\r
95 +notmuch_global_get_verbose (notmuch_config_t *config);
\r
98 +notmuch_global_get_no_hooks (notmuch_config_t *config);
\r
102 notmuch_run_hook (const char *db_path, const char *hook);
\r
104 diff --git a/notmuch-config.c b/notmuch-config.c
\r
105 index 6845e3c..4cb29eb 100644
\r
106 --- a/notmuch-config.c
\r
107 +++ b/notmuch-config.c
\r
108 @@ -118,6 +118,9 @@ struct _notmuch_config {
\r
109 notmuch_bool_t maildir_synchronize_flags;
\r
110 const char **search_exclude_tags;
\r
111 size_t search_exclude_tags_length;
\r
113 + /* global options */
\r
114 + notmuch_global_options_t global_options;
\r
118 @@ -883,3 +886,29 @@ notmuch_config_set_maildir_synchronize_flags (notmuch_config_t *config,
\r
119 "maildir", "synchronize_flags", synchronize_flags);
\r
120 config->maildir_synchronize_flags = synchronize_flags;
\r
123 +/* global options */
\r
125 +notmuch_global_set (notmuch_config_t *config,
\r
126 + const notmuch_global_options_t *global_options)
\r
128 + config->global_options = *global_options;
\r
132 +notmuch_global_get_debug (notmuch_config_t *config)
\r
134 + return config->global_options.debug;
\r
138 +notmuch_global_get_verbose (notmuch_config_t *config)
\r
140 + return config->global_options.verbose;
\r
144 +notmuch_global_get_no_hooks (notmuch_config_t *config)
\r
146 + return config->global_options.no_hooks;
\r
148 diff --git a/notmuch.c b/notmuch.c
\r
149 index 78d29a8..11cdfd7 100644
\r
152 @@ -252,11 +252,19 @@ main (int argc, char *argv[])
\r
153 notmuch_bool_t print_help=FALSE, print_version=FALSE;
\r
156 + notmuch_global_options_t global_options = {
\r
158 + .verbose = FALSE,
\r
159 + .no_hooks = FALSE,
\r
162 notmuch_opt_desc_t options[] = {
\r
163 { NOTMUCH_OPT_BOOLEAN, &print_help, "help", 'h', 0 },
\r
164 { NOTMUCH_OPT_BOOLEAN, &print_version, "version", 'v', 0 },
\r
165 { NOTMUCH_OPT_STRING, &config_file_name, "config", 'c', 0 },
\r
166 + { NOTMUCH_OPT_BOOLEAN, &global_options.debug, "debug", 'd', 0 },
\r
167 + { NOTMUCH_OPT_BOOLEAN, &global_options.verbose, "verbose", 'V', 0 },
\r
168 + { NOTMUCH_OPT_BOOLEAN, &global_options.no_hooks, "no-hooks", 'N', 0 },
\r
172 @@ -300,6 +308,8 @@ main (int argc, char *argv[])
\r
176 + notmuch_global_set (config, &global_options);
\r
178 ret = (command->function)(config, argc - opt_index, argv + opt_index);
\r
180 notmuch_config_close (config);
\r