]> git.cworth.org Git - notmuch/blobdiff - notmuch-restore.c
cli: change argument parsing convention for subcommands
[notmuch] / notmuch-restore.c
index f095f64a76b7054dbda62b1fd8f9f4efa975117b..f530bb4ed9388833e91a70cecd321c9daeb521d2 100644 (file)
@@ -44,6 +44,8 @@ notmuch_restore_command (unused (void *ctx), int argc, char *argv[])
 
     synchronize_flags = notmuch_config_get_maildir_synchronize_flags (config);
 
+    argc--; argv++; /* skip subcommand argument */
+
     if (argc) {
        input = fopen (argv[0], "r");
        if (input == NULL) {
@@ -87,10 +89,13 @@ notmuch_restore_command (unused (void *ctx), int argc, char *argv[])
        file_tags = xstrndup (line + match[2].rm_so,
                              match[2].rm_eo - match[2].rm_so);
 
-       message = notmuch_database_find_message (notmuch, message_id);
-       if (message == NULL) {
-           fprintf (stderr, "Warning: Cannot apply tags to missing message: %s\n",
-                    message_id);
+       status = notmuch_database_find_message (notmuch, message_id, &message);
+       if (status || message == NULL) {
+           fprintf (stderr, "Warning: Cannot apply tags to %smessage: %s\n",
+                    message ? "" : "missing ", message_id);
+           if (status)
+               fprintf (stderr, "%s\n",
+                        notmuch_status_to_string(status));
            goto NEXT_LINE;
        }