unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: david@tethera.net
To: notmuch@notmuchmail.org
Cc: David Bremner <bremner@debian.org>
Subject: [PATCH 3/6] notmuch-dump: update handling of file name argument
Date: Mon, 10 Oct 2011 10:49:18 -0300	[thread overview]
Message-ID: <1318254561-25386-4-git-send-email-david@tethera.net> (raw)
In-Reply-To: <1318254561-25386-1-git-send-email-david@tethera.net>

From: David Bremner <bremner@debian.org>

We permit -- as an "option processing terminator".

Currently this does not do anything useful, but we plan to add
search terms after the --.
---
 notmuch-dump.c |   27 ++++++++++++++++-----------
 1 files changed, 16 insertions(+), 11 deletions(-)

diff --git a/notmuch-dump.c b/notmuch-dump.c
index 7e7bc17..610144e 100644
--- a/notmuch-dump.c
+++ b/notmuch-dump.c
@@ -26,7 +26,7 @@ notmuch_dump_command (unused (void *ctx), int argc, char *argv[])
     notmuch_config_t *config;
     notmuch_database_t *notmuch;
     notmuch_query_t *query;
-    FILE *output;
+    FILE *output = stdout;
     notmuch_messages_t *messages;
     notmuch_message_t *message;
     notmuch_tags_t *tags;
@@ -40,23 +40,28 @@ notmuch_dump_command (unused (void *ctx), int argc, char *argv[])
     if (notmuch == NULL)
 	return 1;
 
-    query = notmuch_query_create (notmuch, "");
-    if (query == NULL) {
-	fprintf (stderr, "Out of memory\n");
-	return 1;
-    }
-    notmuch_query_set_sort (query, NOTMUCH_SORT_MESSAGE_ID);
-
-    if (argc) {
+    if (argc && strcmp (argv[0], "--") != 0) {
 	output = fopen (argv[0], "w");
 	if (output == NULL) {
 	    fprintf (stderr, "Error opening %s for writing: %s\n",
 		     argv[0], strerror (errno));
 	    return 1;
 	}
-    } else {
-	output = stdout;
+	argc--;
+	argv++;
+    }
+
+    if (argc && strcmp (argv[0], "--") == 0){
+	argc--;
+	argv++;
+    }
+
+    query = notmuch_query_create (notmuch, "");
+    if (query == NULL) {
+	fprintf (stderr, "Out of memory\n");
+	return 1;
     }
+    notmuch_query_set_sort (query, NOTMUCH_SORT_MESSAGE_ID);
 
     for (messages = notmuch_query_search_messages (query);
 	 notmuch_messages_valid (messages);
-- 
1.7.6.3

  parent reply	other threads:[~2011-10-10 13:50 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-07  0:20 output file argument to notmuch dump David Bremner
2011-10-07  0:37 ` Dmitry Kurochkin
2011-10-07  0:53   ` David Bremner
2011-10-07  1:43     ` Tom Prince
2011-10-07  1:14 ` Jameson Graef Rollins
2011-10-07 10:23 ` Jesse Rosenthal
2011-10-07 11:15   ` Tomi Ollila
2011-10-07 17:22     ` Jameson Graef Rollins
2011-10-10  7:32       ` Tomi Ollila
2011-10-09 16:01 ` David Bremner
2011-10-10 13:49   ` david
2011-10-10 13:49     ` [PATCH 1/6] test: update dump-restore to use redirection instead of filename args david
2011-10-10 13:49     ` [PATCH 2/6] test: add tests for command line arguments to notmuch-dump david
2011-10-10 13:49     ` david [this message]
2011-10-10 13:49     ` [PATCH 4/6] notmuch-dump: treat any remaining arguments after the filename as search terms david
2011-10-10 13:49     ` [PATCH 5/6] test: all dump-restore tests should be working now david
2011-10-10 13:49     ` [PATCH 6/6] notmuch-dump: deprecate use of output file argument david
2011-10-16 20:34     ` Thomas Schwinge
2011-10-16 23:25       ` Re: David Bremner
2011-10-10 13:59   ` output file argument to notmuch dump Tomi Ollila
2011-10-10 14:25     ` David Bremner
2011-10-10 16:41   ` Jameson Graef Rollins
2011-10-11  2:12     ` 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=1318254561-25386-4-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).