[PATCH v3 09/20] insert: parse and apply command-line tag operations

Peter Wang novalazy at gmail.com
Sat Jan 19 16:49:53 PST 2013


Parse +tag and -tag operations on the 'insert' command-line
and apply them to the inserted message in addition to new.tags.
---
 notmuch-insert.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/notmuch-insert.c b/notmuch-insert.c
index 8388d07..b0ac174 100644
--- a/notmuch-insert.c
+++ b/notmuch-insert.c
@@ -235,7 +235,9 @@ notmuch_insert_command (void *ctx, int argc, char *argv[])
     const char **new_tags;
     size_t new_tags_length;
     tag_op_list_t *tag_ops;
+    char *query_string = NULL;
     char *maildir;
+    int opt_index = 1;
     unsigned int i;
     notmuch_bool_t ret;
 
@@ -256,6 +258,15 @@ notmuch_insert_command (void *ctx, int argc, char *argv[])
 	    return 1;
     }
 
+    if (parse_tag_command_line (ctx, argc - opt_index, argv + opt_index,
+				&query_string, tag_ops))
+	return 1;
+
+    if (*query_string != '\0') {
+	fprintf (stderr, "Error: unexpected query string: %s\n", query_string);
+	return 1;
+    }
+
     maildir = talloc_asprintf (ctx, "%s", db_path);
     if (! maildir) {
 	fprintf (stderr, "Out of memory\n");
-- 
1.7.12.1



More information about the notmuch mailing list