[PATCH 2/4] notmuch-dump: convert to notmuch-opts argument handling.
authorDavid Bremner <david@tethera.net>
Sun, 4 Dec 2011 15:47:53 +0000 (11:47 +2000)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:40:33 +0000 (09:40 -0800)
2b/fe90aa6945e7e71dd97f873c4ae91a5be82ca5 [new file with mode: 0644]

diff --git a/2b/fe90aa6945e7e71dd97f873c4ae91a5be82ca5 b/2b/fe90aa6945e7e71dd97f873c4ae91a5be82ca5
new file mode 100644 (file)
index 0000000..399d455
--- /dev/null
@@ -0,0 +1,123 @@
+Return-Path: <bremner@tethera.net>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+       by olra.theworths.org (Postfix) with ESMTP id 60958429E38\r
+       for <notmuch@notmuchmail.org>; Sun,  4 Dec 2011 07:48:20 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -2.3\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-2.3 tagged_above=-999 required=5\r
+       tests=[RCVD_IN_DNSWL_MED=-2.3] autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+       by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+       with ESMTP id dTvQ5mja4faG for <notmuch@notmuchmail.org>;\r
+       Sun,  4 Dec 2011 07:48:19 -0800 (PST)\r
+Received: from tempo.its.unb.ca (tempo.its.unb.ca [131.202.1.21])\r
+       (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))\r
+       (No client certificate requested)\r
+       by olra.theworths.org (Postfix) with ESMTPS id 85E6B429E30\r
+       for <notmuch@notmuchmail.org>; Sun,  4 Dec 2011 07:48:15 -0800 (PST)\r
+Received: from zancas.localnet\r
+       (fctnnbsc36w-156034079193.pppoe-dynamic.High-Speed.nb.bellaliant.net\r
+       [156.34.79.193]) (authenticated bits=0)\r
+       by tempo.its.unb.ca (8.13.8/8.13.8) with ESMTP id pB4Fm8UT005363\r
+       (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NO);\r
+       Sun, 4 Dec 2011 11:48:11 -0400\r
+Received: from bremner by zancas.localnet with local (Exim 4.77)\r
+       (envelope-from <bremner@tethera.net>)\r
+       id 1RXEIS-0001oo-7m; Sun, 04 Dec 2011 11:48:08 -0400\r
+From: David Bremner <david@tethera.net>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH 2/4] notmuch-dump: convert to notmuch-opts argument handling.\r
+Date: Sun,  4 Dec 2011 11:47:53 -0400\r
+Message-Id: <1323013675-6929-3-git-send-email-david@tethera.net>\r
+X-Mailer: git-send-email 1.7.7.3\r
+In-Reply-To: <1323013675-6929-1-git-send-email-david@tethera.net>\r
+References: <1323013675-6929-1-git-send-email-david@tethera.net>\r
+Cc: David Bremner <bremner@debian.org>\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+       <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Sun, 04 Dec 2011 15:48:21 -0000\r
+\r
+From: David Bremner <bremner@debian.org>\r
+\r
+The output file is handled via positional arguments. There are\r
+currently no "normal" options.\r
+---\r
+ notmuch-dump.c |   32 ++++++++++++++++++++------------\r
+ 1 files changed, 20 insertions(+), 12 deletions(-)\r
+\r
+diff --git a/notmuch-dump.c b/notmuch-dump.c\r
+index a490917..6fbdc81 100644\r
+--- a/notmuch-dump.c\r
++++ b/notmuch-dump.c\r
+@@ -19,6 +19,7 @@\r
+  */\r
\r
+ #include "notmuch-client.h"\r
++#include "notmuch-opts.h"\r
\r
+ int\r
+ notmuch_dump_command (unused (void *ctx), int argc, char *argv[])\r
+@@ -41,27 +42,34 @@ notmuch_dump_command (unused (void *ctx), int argc, char *argv[])\r
+     if (notmuch == NULL)\r
+       return 1;\r
\r
+-    argc--; argv++; /* skip subcommand argument */\r
++    char *output_file_name = NULL;\r
++    int opt_index;\r
\r
+-    if (argc && strcmp (argv[0], "--") != 0) {\r
++    notmuch_opt_desc_t options[] = {\r
++      { "out-file", 'o', NOTMUCH_OPT_POSITION, 0, &output_file_name },\r
++      { 0, 0, 0, 0, 0 }\r
++    };\r
++\r
++    opt_index = notmuch_parse_args (argc, argv, options, 1);\r
++\r
++    if (opt_index < 0) {\r
++      /* diagnostics already printed */\r
++      exit(1);\r
++    }\r
++\r
++    if (output_file_name) {\r
+       fprintf (stderr, "Warning: the output file argument of dump is deprecated.\n");\r
+-      output = fopen (argv[0], "w");\r
++      output = fopen (output_file_name, "w");\r
+       if (output == NULL) {\r
+           fprintf (stderr, "Error opening %s for writing: %s\n",\r
+-                   argv[0], strerror (errno));\r
++                   output_file_name, strerror (errno));\r
+           return 1;\r
+       }\r
+-      argc--;\r
+-      argv++;\r
+     }\r
\r
+-    if (argc && strcmp (argv[0], "--") == 0){\r
+-      argc--;\r
+-      argv++;\r
+-    }\r
\r
+-    if (argc) {\r
+-      query_str = query_string_from_args (notmuch, argc, argv);\r
++    if (opt_index < argc) {\r
++      query_str = query_string_from_args (notmuch, argc-opt_index, argv+opt_index);\r
+       if (query_str == NULL) {\r
+           fprintf (stderr, "Out of memory.\n");\r
+           return 1;\r
+-- \r
+1.7.7.3\r
+\r