this just accesses the cached config data

API is to be decided; maybe we should return a status value.
---
 lib/config.cc          |  6 ++++++
 lib/notmuch.h          |  2 ++
 test/T590-libconfig.sh | 15 +++++++++++++++
 3 files changed, 23 insertions(+)

diff --git a/lib/config.cc b/lib/config.cc
index 2d4c3801..0a91ec03 100644
--- a/lib/config.cc
+++ b/lib/config.cc
@@ -219,3 +219,9 @@ _notmuch_config_load_from_database (notmuch_database_t 
*notmuch)
 
     return status;
 }
+
+const char *
+notmuch_config_get (notmuch_database_t *notmuch, const char *key) {
+
+    return _notmuch_string_map_get (notmuch->config, key);
+}
diff --git a/lib/notmuch.h b/lib/notmuch.h
index e61634a1..777116bb 100644
--- a/lib/notmuch.h
+++ b/lib/notmuch.h
@@ -2397,6 +2397,8 @@ notmuch_config_list_move_to_next (notmuch_config_list_t 
*config_list);
 void
 notmuch_config_list_destroy (notmuch_config_list_t *config_list);
 
+const char *
+notmuch_config_get (notmuch_database_t *notmuch, const char *key);
 
 /**
  * get the current default indexing options for a given database.
diff --git a/test/T590-libconfig.sh b/test/T590-libconfig.sh
index 8c34acf9..8a4519e9 100755
--- a/test/T590-libconfig.sh
+++ b/test/T590-libconfig.sh
@@ -169,4 +169,19 @@ notmuch restore --include=config <EXPECTED
 notmuch dump --include=config >OUTPUT
 test_expect_equal_file EXPECTED OUTPUT
 
+test_begin_subtest "notmuch_config_get"
+cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR}
+{
+   printf("test.key1 = %s\n", notmuch_config_get (db, "test.key1"));
+   printf("test.key2 = %s\n", notmuch_config_get (db, "test.key2"));
+}
+EOF
+cat <<'EOF' >EXPECTED
+== stdout ==
+test.key1 = testvalue1
+test.key2 = testvalue2
+== stderr ==
+EOF
+test_expect_equal_file EXPECTED OUTPUT
+
 test_done
-- 
2.28.0
_______________________________________________
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org

Reply via email to