Add a command to list all keys in a given configuration section. One use is as follows: a MUA may prefer to store data in a central notmuch configuration file so that the data is accessible across different machines, e.g. an addressbook. The list command helps to implement features such as tab completion on the keys. --- notmuch-config.c | 27 +++++++++++++++++++++++++++ 1 files changed, 27 insertions(+), 0 deletions(-) diff --git a/notmuch-config.c b/notmuch-config.c index e9b2750..595cf54 100644 --- a/notmuch-config.c +++ b/notmuch-config.c @@ -799,6 +799,31 @@ notmuch_config_command_set (void *ctx, char *item, int argc, char *argv[]) return ret; } +static int +notmuch_config_command_list (void *ctx, char *group) +{ + notmuch_config_t *config; + char **keys; + size_t i, length; + + config = notmuch_config_open (ctx, NULL, NULL); + if (config == NULL) + return 1; + + keys = g_key_file_get_keys (config->key_file, + group, &length, NULL); + if (keys != NULL) { + for (i = 0; i < length; i++) + printf ("%s\n", keys[i]); + + free (keys); + } + + notmuch_config_close (config); + + return 0; +} + int notmuch_config_command (void *ctx, int argc, char *argv[]) { @@ -813,6 +838,8 @@ notmuch_config_command (void *ctx, int argc, char *argv[]) return notmuch_config_command_get (ctx, argv[1]); else if (strcmp (argv[0], "set") == 0) return notmuch_config_command_set (ctx, argv[1], argc - 2, argv + 2); + else if (strcmp (argv[0], "list") == 0) + return notmuch_config_command_list (ctx, argv[1]); fprintf (stderr, "Unrecognized argument for notmuch config: %s\n", argv[0]); -- 1.7.4.4