unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: David Bremner <david@tethera.net>
To: notmuch@notmuchmail.org
Subject: [PATCH 4/4] cli: add standard option processing to config and setup
Date: Mon,  6 Apr 2015 05:59:34 +0900	[thread overview]
Message-ID: <1428267574-28797-5-git-send-email-david@tethera.net> (raw)
In-Reply-To: <1428267574-28797-1-git-send-email-david@tethera.net>

In particular this fixes a recently encountered bug where the
"--config" argument to "notmuch setup" is silently ignored, which the
unpleasant consequence of overwriting the users config file.
---
 notmuch-config.c | 12 ++++++++++++
 notmuch-setup.c  | 12 ++++++++++++
 2 files changed, 24 insertions(+)

diff --git a/notmuch-config.c b/notmuch-config.c
index 2d5c297..054dd3b 100644
--- a/notmuch-config.c
+++ b/notmuch-config.c
@@ -872,6 +872,18 @@ int
 notmuch_config_command (notmuch_config_t *config, int argc, char *argv[])
 {
     int ret;
+    int opt_index;
+
+    notmuch_opt_desc_t options[] = {
+	{ NOTMUCH_OPT_INHERIT, (void *) &notmuch_shared_options, NULL, 0, 0 },
+	{ 0, 0, 0, 0, 0 }
+    };
+
+    opt_index = parse_arguments (argc, argv, options, 1);
+    if (opt_index < 0)
+	return EXIT_FAILURE;
+
+    notmuch_process_shared_options (argv[0]);
 
     argc--; argv++; /* skip subcommand argument */
 
diff --git a/notmuch-setup.c b/notmuch-setup.c
index 36a6171..5fc6e25 100644
--- a/notmuch-setup.c
+++ b/notmuch-setup.c
@@ -133,6 +133,7 @@ notmuch_setup_command (notmuch_config_t *config,
     size_t new_tags_len;
     const char **search_exclude_tags;
     size_t search_exclude_tags_len;
+    int opt_index;
 
 #define prompt(format, ...)					\
     do {							\
@@ -145,6 +146,17 @@ notmuch_setup_command (notmuch_config_t *config,
 	chomp_newline (response);				\
     } while (0)
 
+    notmuch_opt_desc_t options[] = {
+	{ NOTMUCH_OPT_INHERIT, (void *) &notmuch_shared_options, NULL, 0, 0 },
+	{ 0, 0, 0, 0, 0 }
+    };
+
+    opt_index = parse_arguments (argc, argv, options, 1);
+    if (opt_index < 0)
+	return EXIT_FAILURE;
+
+    notmuch_process_shared_options (argv[0]);
+
     if (notmuch_config_is_new (config))
 	welcome_message_pre_setup ();
 
-- 
2.1.4

  parent reply	other threads:[~2015-04-05 21:34 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-05 20:59 argument parsing refactor, add shared options David Bremner
2015-04-05 20:59 ` [PATCH 1/4] cli: ignore config argument of notmuch_help_command David Bremner
2015-04-05 20:59 ` [PATCH 2/4] cli: refactor notmuch_help_command David Bremner
2015-04-05 20:59 ` [PATCH 3/4] cli: define shared options, use for --help and --version David Bremner
2015-04-05 20:59 ` David Bremner [this message]
2015-04-05 21:34   ` [PATCH 4/4] cli: add standard option processing to config and setup David Bremner
2015-04-06 12:22     ` argument parsing refactoring, round 2 David Bremner
2015-04-06 12:22       ` [Patch v2 1/4] cli: ignore config argument of notmuch_help_command David Bremner
2015-04-06 12:22       ` [Patch v2 2/4] cli: refactor notmuch_help_command David Bremner
2015-04-06 12:22       ` [Patch v2 3/4] cli: define shared options, use for --help and --version David Bremner
2015-04-07  7:22         ` Mark Walters
2015-04-06 12:22       ` [Patch v2 4/4] cli: add standard option processing to config and setup David Bremner
2015-04-07  7:24         ` Mark Walters
2015-04-07 10:20           ` David Bremner
2015-04-07  7:19       ` argument parsing refactoring, round 2 Mark Walters
2015-04-07 19:30         ` argument parsing refactoring round3 David Bremner
2015-04-07 19:30           ` [PATCH 1/4] cli: ignore config argument of notmuch_help_command David Bremner
2015-04-07 19:30           ` [PATCH 2/4] cli: refactor notmuch_help_command David Bremner
2015-04-07 19:30           ` [PATCH 3/4] cli: define shared options, use for --help and --version David Bremner
2015-04-07 19:30           ` [PATCH 4/4] cli: add standard option processing to config, help and setup David Bremner
2015-04-08 14:14             ` [PATCH] fixup! " David Bremner
2015-04-08 14:31           ` argument parsing refactoring round3 guyzmo
2015-04-08 23:53             ` David Bremner
2015-04-11  0:01               ` David Bremner
2015-04-25 19:56                 ` Tomi Ollila
2015-06-02  4:43           ` 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=1428267574-28797-5-git-send-email-david@tethera.net \
    --to=david@tethera.net \
    --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).