]> git.cworth.org Git - obsolete/notmuch-old/blobdiff - notmuch-config.c
config: Check 'config get' arity exactly
[obsolete/notmuch-old] / notmuch-config.c
index 61fda3ea4bafd49ef14d075c2cef70c8d5f2a20c..f9eb97780c54673ca61bcae292e077c22b66745f 100644 (file)
@@ -377,7 +377,8 @@ notmuch_config_open (void *ctx,
 
     if (notmuch_config_get_search_exclude_tags (config, &tmp) == NULL) {
        if (is_new) {
-           /* We do not set default search_exclude_tags for 0.12 */
+           const char *tags[] = { "deleted", "spam" };
+           notmuch_config_set_search_exclude_tags (config, tags, 2);
        } else {
            notmuch_config_set_search_exclude_tags (config, NULL, 0);
        }
@@ -750,7 +751,7 @@ notmuch_config_command_get (void *ctx, char *item)
        for (i = 0; i < length; i++)
            printf ("%s\n", value[i]);
 
-       free (value);
+       g_strfreev (value);
     }
 
     notmuch_config_close (config);
@@ -803,15 +804,26 @@ notmuch_config_command (void *ctx, int argc, char *argv[])
 {
     argc--; argv++; /* skip subcommand argument */
 
-    if (argc < 2) {
-       fprintf (stderr, "Error: notmuch config requires at least two arguments.\n");
+    if (argc < 1) {
+       fprintf (stderr, "Error: notmuch config requires at least one argument.\n");
        return 1;
     }
 
-    if (strcmp (argv[0], "get") == 0)
+    if (strcmp (argv[0], "get") == 0) {
+       if (argc != 2) {
+           fprintf (stderr, "Error: notmuch config get requires exactly "
+                    "one argument.\n");
+           return 1;
+       }
        return notmuch_config_command_get (ctx, argv[1]);
-    else if (strcmp (argv[0], "set") == 0)
+    } else if (strcmp (argv[0], "set") == 0) {
+       if (argc < 2) {
+           fprintf (stderr, "Error: notmuch config set requires at least "
+                    "one argument.\n");
+           return 1;
+       }
        return notmuch_config_command_set (ctx, argv[1], argc - 2, argv + 2);
+    }
 
     fprintf (stderr, "Unrecognized argument for notmuch config: %s\n",
             argv[0]);