]> git.notmuchmail.org Git - notmuch/blobdiff - notmuch-config.c
cli: tell how many messages were precisely matched when expected 1 match
[notmuch] / notmuch-config.c
index 2d5c297b7f5f2996b89c6e7c9502df90a06c93d6..01bb185990bb31f2965ab0a0aab7f967ea5c4232 100644 (file)
@@ -750,6 +750,8 @@ _item_split (char *item, char **group, char **key)
     return 0;
 }
 
+#define BUILT_WITH_PREFIX "built_with."
+
 static int
 notmuch_config_command_get (notmuch_config_t *config, char *item)
 {
@@ -773,6 +775,9 @@ notmuch_config_command_get (notmuch_config_t *config, char *item)
        tags = notmuch_config_get_new_tags (config, &length);
        for (i = 0; i < length; i++)
            printf ("%s\n", tags[i]);
+    } else if (STRNCMP_LITERAL (item, BUILT_WITH_PREFIX) == 0) {
+       printf ("%s\n",
+               notmuch_built_with (item + strlen (BUILT_WITH_PREFIX)) ? "true" : "false");
     } else {
        char **value;
        size_t i, length;
@@ -804,6 +809,11 @@ notmuch_config_command_set (notmuch_config_t *config, char *item, int argc, char
 {
     char *group, *key;
 
+    if (STRNCMP_LITERAL (item, BUILT_WITH_PREFIX) == 0) {
+       fprintf (stderr, "Error: read only option: %s\n", item);
+       return 1;
+    }
+
     if (_item_split (item, &group, &key))
        return 1;
 
@@ -830,6 +840,18 @@ notmuch_config_command_set (notmuch_config_t *config, char *item, int argc, char
     return notmuch_config_save (config);
 }
 
+static
+void
+_notmuch_config_list_built_with ()
+{
+    printf("%scompact=%s\n",
+          BUILT_WITH_PREFIX,
+          notmuch_built_with ("compact") ? "true" : "false");
+    printf("%sfield_processor=%s\n",
+          BUILT_WITH_PREFIX,
+          notmuch_built_with ("field_processor") ? "true" : "false");
+}
+
 static int
 notmuch_config_command_list (notmuch_config_t *config)
 {
@@ -865,6 +887,7 @@ notmuch_config_command_list (notmuch_config_t *config)
 
     g_strfreev (groups);
 
+    _notmuch_config_list_built_with ();
     return 0;
 }
 
@@ -872,8 +895,19 @@ int
 notmuch_config_command (notmuch_config_t *config, int argc, char *argv[])
 {
     int ret;
+    int opt_index;
+
+    opt_index = notmuch_minimal_options ("config", argc, argv);
+    if (opt_index < 0)
+       return EXIT_FAILURE;
+
+    if (notmuch_requested_db_uuid)
+       fprintf (stderr, "Warning: ignoring --uuid=%s\n",
+                notmuch_requested_db_uuid);
 
-    argc--; argv++; /* skip subcommand argument */
+    /* skip at least subcommand argument */
+    argc-= opt_index;
+    argv+= opt_index;
 
     if (argc < 1) {
        fprintf (stderr, "Error: notmuch config requires at least one argument.\n");