From: David Bremner <david@tethera.net>
To: notmuch@notmuchmail.org
Cc: David Bremner <bremner@debian.org>
Subject: [PATCH 2/4] notmuch-dump: convert to command-line-arguments
Date: Wed, 7 Dec 2011 08:34:38 -0400 [thread overview]
Message-ID: <1323261280-29907-2-git-send-email-david@tethera.net> (raw)
In-Reply-To: <1323261280-29907-1-git-send-email-david@tethera.net>
From: David Bremner <bremner@debian.org>
The output file is handled via positional arguments. There are
currently no "normal" options.
---
notmuch-dump.c | 31 +++++++++++++++++++------------
1 files changed, 19 insertions(+), 12 deletions(-)
diff --git a/notmuch-dump.c b/notmuch-dump.c
index a490917..c568734 100644
--- a/notmuch-dump.c
+++ b/notmuch-dump.c
@@ -41,27 +41,34 @@ notmuch_dump_command (unused (void *ctx), int argc, char *argv[])
if (notmuch == NULL)
return 1;
- argc--; argv++; /* skip subcommand argument */
+ char *output_file_name = NULL;
+ int opt_index;
- if (argc && strcmp (argv[0], "--") != 0) {
+ notmuch_opt_desc_t options[] = {
+ { "out-file", 'o', NOTMUCH_OPT_POSITION, 0, &output_file_name },
+ { 0, 0, 0, 0, 0 }
+ };
+
+ opt_index = parse_arguments (argc, argv, options, 1);
+
+ if (opt_index < 0) {
+ /* diagnostics already printed */
+ exit(1);
+ }
+
+ if (output_file_name) {
fprintf (stderr, "Warning: the output file argument of dump is deprecated.\n");
- output = fopen (argv[0], "w");
+ output = fopen (output_file_name, "w");
if (output == NULL) {
fprintf (stderr, "Error opening %s for writing: %s\n",
- argv[0], strerror (errno));
+ output_file_name, strerror (errno));
return 1;
}
- argc--;
- argv++;
}
- if (argc && strcmp (argv[0], "--") == 0){
- argc--;
- argv++;
- }
- if (argc) {
- query_str = query_string_from_args (notmuch, argc, argv);
+ if (opt_index < argc) {
+ query_str = query_string_from_args (notmuch, argc-opt_index, argv+opt_index);
if (query_str == NULL) {
fprintf (stderr, "Out of memory.\n");
return 1;
--
1.7.7.3
next prev parent reply other threads:[~2011-12-07 12:34 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-12-04 15:47 David Bremner
2011-12-04 15:47 ` [PATCH 1/4] notmuch-opts.[ch]: new argument parsing framework for notmuch David Bremner
2011-12-06 20:41 ` Jani Nikula
2011-12-07 12:27 ` David Bremner
2011-12-07 12:34 ` [PATCH 1/4] command-line-arguments.[ch]: " David Bremner
2011-12-07 12:34 ` David Bremner [this message]
2011-12-07 12:34 ` [PATCH 3/4] notmuch-restore: convert to command-line-arguments David Bremner
2011-12-07 12:34 ` [PATCH 4/4] notmuch-search: " David Bremner
2011-12-07 19:26 ` David Bremner
2011-12-07 19:26 ` [PATCH v4 1/5] command-line-arguments.[ch]: new argument parsing framework for notmuch David Bremner
2011-12-09 1:40 ` David Bremner
2011-12-07 19:26 ` [PATCH v4 2/5] test: tests for command-line-arguments.c David Bremner
2011-12-07 19:26 ` [PATCH v4 3/5] notmuch-dump: convert to command-line-arguments David Bremner
2011-12-07 19:26 ` [PATCH v4 4/5] notmuch-restore: " David Bremner
2011-12-07 19:26 ` [PATCH v4 5/5] notmuch-search: " David Bremner
2011-12-06 20:55 ` [PATCH 1/4] notmuch-opts.[ch]: new argument parsing framework for notmuch Jani Nikula
2011-12-04 15:47 ` [PATCH 2/4] notmuch-dump: convert to notmuch-opts argument handling David Bremner
2011-12-06 20:43 ` Jani Nikula
2011-12-04 15:47 ` [PATCH 3/4] notmuch-restore: " David Bremner
2011-12-06 20:48 ` Jani Nikula
2011-12-04 15:47 ` [PATCH 4/4] notmuch-search: convert to notmuch-opts argument parsing 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=1323261280-29907-2-git-send-email-david@tethera.net \
--to=david@tethera.net \
--cc=bremner@debian.org \
--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).