unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [PATCH 1/2] config: Add 'config list' command
@ 2012-03-20 22:31 Peter Wang
  2012-03-20 22:31 ` [PATCH 2/2] man: Document " Peter Wang
                   ` (5 more replies)
  0 siblings, 6 replies; 36+ messages in thread
From: Peter Wang @ 2012-03-20 22:31 UTC (permalink / raw)
  To: notmuch

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

^ permalink raw reply related	[flat|nested] 36+ messages in thread

end of thread, other threads:[~2012-04-28 13:51 UTC | newest]

Thread overview: 36+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-03-20 22:31 [PATCH 1/2] config: Add 'config list' command Peter Wang
2012-03-20 22:31 ` [PATCH 2/2] man: Document " Peter Wang
2012-03-21 18:30 ` [PATCH 1/2] config: Add " Tomi Ollila
2012-03-21 22:52   ` Peter Wang
2012-03-26 15:03   ` Jameson Graef Rollins
2012-03-26 14:56 ` Jameson Graef Rollins
2012-03-30 23:15 ` [PATCH v2] " Peter Wang
2012-03-30 23:15   ` [PATCH v2 1/5] config: Fix free in 'config get' implementation Peter Wang
2012-03-30 23:15   ` [PATCH v2 2/5] test: Add tests for 'config' command Peter Wang
2012-03-31  7:45     ` Mark Walters
2012-03-31 21:47       ` Jameson Graef Rollins
2012-03-30 23:15   ` [PATCH v2 3/5] test: Add broken test for 'config list' Peter Wang
2012-03-30 23:15   ` [PATCH v2 4/5] config: Add 'config list' command Peter Wang
2012-03-30 23:15   ` [PATCH v2 5/5] man: Document " Peter Wang
2012-04-06  1:48 ` [PATCH v3 0/5] Add " Peter Wang
2012-04-06  1:48   ` [PATCH v3 1/5] config: Fix free in 'config get' implementation Peter Wang
2012-04-06  1:48   ` [PATCH v3 2/5] test: Add tests for 'config' command Peter Wang
2012-04-10  7:30     ` Jameson Graef Rollins
2012-04-06  1:48   ` [PATCH v3 3/5] test: Add broken test for 'config list' Peter Wang
2012-04-06  1:48   ` [PATCH v3 4/5] config: Add 'config list' command Peter Wang
2012-04-10  7:22     ` Jameson Graef Rollins
2012-04-10  8:31       ` Peter Wang
2012-04-06  1:48   ` [PATCH v3 5/5] man: Document " Peter Wang
2012-04-14  1:41 ` [PATCH v4 0/6] Config-related patches Peter Wang
2012-04-14  1:41   ` [PATCH v4 1/6] config: Fix free in 'config get' implementation Peter Wang
2012-04-25  2:29     ` David Bremner
2012-04-14  1:41   ` [PATCH v4 2/6] config: Check 'config get' arity exactly Peter Wang
2012-04-28 13:51     ` David Bremner
2012-04-14  1:41   ` [PATCH v4 3/6] test: Add tests for 'config' command Peter Wang
2012-04-14  1:41   ` [PATCH v4 4/6] test: Add broken test for 'config list' Peter Wang
2012-04-14  1:41   ` [PATCH v4 5/6] config: Add 'config list' command Peter Wang
2012-04-14  1:41   ` [PATCH v4 6/6] man: Document " Peter Wang
2012-04-14  8:25   ` [PATCH v4 0/6] Config-related patches Mark Walters
2012-04-14 19:33     ` Jameson Graef Rollins
2012-04-25  8:06     ` Mark Walters
2012-04-14 19:32   ` Jameson Graef Rollins

Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).