--- /dev/null
+Return-Path: <bremner@pivot.cs.unb.ca>\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 D7208429E2F\r
+ for <notmuch@notmuchmail.org>; Wed, 7 Dec 2011 11:26:55 -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 edrw6pvPP8sx for <notmuch@notmuchmail.org>;\r
+ Wed, 7 Dec 2011 11:26:54 -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 ED73F429E37\r
+ for <notmuch@notmuchmail.org>; Wed, 7 Dec 2011 11:26:49 -0800 (PST)\r
+Received: from convex-new.cs.unb.ca ([131.202.13.154])\r
+ by tempo.its.unb.ca (8.13.8/8.13.8) with ESMTP id pB7JQhNn021341;\r
+ Wed, 7 Dec 2011 15:26:46 -0400\r
+Received: from bremner by convex-new.cs.unb.ca with local (Exim 4.72)\r
+ (envelope-from <bremner@pivot.cs.unb.ca>)\r
+ id 1RYN8d-0004Pp-UW; Wed, 07 Dec 2011 15:26:43 -0400\r
+From: David Bremner <david@tethera.net>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH v4 4/5] notmuch-restore: convert to command-line-arguments\r
+Date: Wed, 7 Dec 2011 15:26:38 -0400\r
+Message-Id: <1323285999-16870-5-git-send-email-david@tethera.net>\r
+X-Mailer: git-send-email 1.7.5.4\r
+In-Reply-To: <1323285999-16870-1-git-send-email-david@tethera.net>\r
+References: <87iplso9c9.fsf@zancas.localnet>\r
+ <1323285999-16870-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: Wed, 07 Dec 2011 19:26:56 -0000\r
+\r
+From: David Bremner <bremner@debian.org>\r
+\r
+The new argument handling is a bit more concise, and bit more\r
+flexible. It allows the input file name to go before the --accumulate\r
+option.\r
+---\r
+ notmuch-restore.c | 37 +++++++++++++++----------------------\r
+ 1 files changed, 15 insertions(+), 22 deletions(-)\r
+\r
+diff --git a/notmuch-restore.c b/notmuch-restore.c\r
+index 13b4325..87d9772 100644\r
+--- a/notmuch-restore.c\r
++++ b/notmuch-restore.c\r
+@@ -18,8 +18,6 @@\r
+ * Author: Carl Worth <cworth@cworth.org>\r
+ */\r
+ \r
+-#include <getopt.h>\r
+-\r
+ #include "notmuch-client.h"\r
+ \r
+ int\r
+@@ -29,12 +27,14 @@ notmuch_restore_command (unused (void *ctx), int argc, char *argv[])\r
+ notmuch_database_t *notmuch;\r
+ notmuch_bool_t synchronize_flags;\r
+ notmuch_bool_t accumulate = FALSE;\r
++ char *input_file_name = NULL;\r
+ FILE *input = stdin;\r
+ char *line = NULL;\r
+ size_t line_size;\r
+ ssize_t line_len;\r
+ regex_t regex;\r
+ int rerr;\r
++ int opt_index;\r
+ \r
+ config = notmuch_config_open (ctx, NULL, NULL);\r
+ if (config == NULL)\r
+@@ -47,37 +47,30 @@ notmuch_restore_command (unused (void *ctx), int argc, char *argv[])\r
+ \r
+ synchronize_flags = notmuch_config_get_maildir_synchronize_flags (config);\r
+ \r
+- struct option options[] = {\r
+- { "accumulate", no_argument, 0, 'a' },\r
+- { 0, 0, 0, 0}\r
++ notmuch_opt_desc_t options[] = {\r
++ { NOTMUCH_OPT_POSITION, &input_file_name, 0, 0, 0 },\r
++ { NOTMUCH_OPT_BOOLEAN, &accumulate, "accumulate", 'a', 0 },\r
++ { 0, 0, 0, 0, 0 }\r
+ };\r
+ \r
+- int opt;\r
+- do {\r
+- opt = getopt_long (argc, argv, "", options, NULL);\r
+-\r
+- switch (opt) {\r
+- case 'a':\r
+- accumulate = 1;\r
+- break;\r
+- case '?':\r
+- return 1;\r
+- break;\r
+- }\r
++ opt_index = parse_arguments (argc, argv, options, 1);\r
+ \r
+- } while (opt != -1);\r
++ if (opt_index < 0) {\r
++ /* diagnostics already printed */\r
++ return 1;\r
++ }\r
+ \r
+- if (optind < argc) {\r
+- input = fopen (argv[optind], "r");\r
++ if (input_file_name) {\r
++ input = fopen (input_file_name, "r");\r
+ if (input == NULL) {\r
+ fprintf (stderr, "Error opening %s for reading: %s\n",\r
+- argv[optind], strerror (errno));\r
++ input_file_name, strerror (errno));\r
+ return 1;\r
+ }\r
+ optind++;\r
+ }\r
+ \r
+- if (optind < argc) {\r
++ if (opt_index < argc) {\r
+ fprintf (stderr,\r
+ "Cannot read dump from more than one file: %s\n",\r
+ argv[optind]);\r
+-- \r
+1.7.5.4\r
+\r