mirror of
https://git.notmuchmail.org/git/notmuch
synced 2024-11-25 04:18:08 +01:00
CLI/config: support set/get with split configuration
There are two small code changes. The main one is to retrieve the possibly updated config file name found during the database opening call. The second change is to allow empty config file names, as a (currently broken) way of specifying that configuration should only be taken from the database.
This commit is contained in:
parent
f5d4349921
commit
77d4b26d3e
2 changed files with 63 additions and 2 deletions
|
@ -454,7 +454,7 @@ main (int argc, char *argv[])
|
||||||
int ret = EXIT_SUCCESS;
|
int ret = EXIT_SUCCESS;
|
||||||
|
|
||||||
notmuch_opt_desc_t options[] = {
|
notmuch_opt_desc_t options[] = {
|
||||||
{ .opt_string = &config_file_name, .name = "config" },
|
{ .opt_string = &config_file_name, .name = "config", .allow_empty = TRUE },
|
||||||
{ .opt_inherit = notmuch_shared_options },
|
{ .opt_inherit = notmuch_shared_options },
|
||||||
{ }
|
{ }
|
||||||
};
|
};
|
||||||
|
@ -581,6 +581,9 @@ main (int argc, char *argv[])
|
||||||
}
|
}
|
||||||
|
|
||||||
if (command->mode & NOTMUCH_COMMAND_CONFIG_OPEN) {
|
if (command->mode & NOTMUCH_COMMAND_CONFIG_OPEN) {
|
||||||
|
if (! config_file_name)
|
||||||
|
config_file_name = notmuch_config_path (notmuch);
|
||||||
|
|
||||||
config = notmuch_config_open (notmuch, config_file_name, command->mode);
|
config = notmuch_config_open (notmuch, config_file_name, command->mode);
|
||||||
if (! config) {
|
if (! config) {
|
||||||
ret = EXIT_FAILURE;
|
ret = EXIT_FAILURE;
|
||||||
|
|
|
@ -215,7 +215,65 @@ EOF
|
||||||
|
|
||||||
test_expect_equal_file EXPECTED OUTPUT
|
test_expect_equal_file EXPECTED OUTPUT
|
||||||
|
|
||||||
|
test_begin_subtest "Set config value ($config)"
|
||||||
|
name=${RANDOM}
|
||||||
|
value=${RANDOM}
|
||||||
|
notmuch config set test${test_count}.${name} ${value}
|
||||||
|
output=$(notmuch config get test${test_count}.${name})
|
||||||
|
notmuch config set test${test_count}.${name}
|
||||||
|
output2=$(notmuch config get test${test_count}.${name})
|
||||||
|
test_expect_equal "${output}+${output2}" "${value}+"
|
||||||
|
|
||||||
|
test_begin_subtest "Set config value in database ($config)"
|
||||||
|
name=${RANDOM}
|
||||||
|
value=${RANDOM}
|
||||||
|
notmuch config set --database test${test_count}.${name} ${value}
|
||||||
|
output=$(notmuch config get test${test_count}.${name})
|
||||||
|
notmuch config set --database test${test_count}.${name}
|
||||||
|
output2=$(notmuch config get test${test_count}.${name})
|
||||||
|
test_expect_equal "${output}+${output2}" "${value}+"
|
||||||
|
|
||||||
|
test_begin_subtest "Config list ($config)"
|
||||||
|
notmuch config list | notmuch_dir_sanitize | sed -e "s/^database.backup_dir=.*$/database.backup_dir/" \
|
||||||
|
-e "s/^database.hook_dir=.*$/database.hook_dir/" \
|
||||||
|
-e "s/^database.path=.*$/database.path/" > OUTPUT
|
||||||
|
cat <<EOF > EXPECTED
|
||||||
|
built_with.compact=true
|
||||||
|
built_with.field_processor=true
|
||||||
|
built_with.retry_lock=true
|
||||||
|
database.backup_dir
|
||||||
|
database.hook_dir
|
||||||
|
database.mail_root=MAIL_DIR
|
||||||
|
database.path
|
||||||
|
maildir.synchronize_flags=true
|
||||||
|
new.ignore=
|
||||||
|
new.tags=unread;inbox
|
||||||
|
search.exclude_tags=
|
||||||
|
user.name=Notmuch Test Suite
|
||||||
|
user.other_email=test_suite_other@notmuchmail.org;test_suite@otherdomain.org
|
||||||
|
user.primary_email=test_suite@notmuchmail.org
|
||||||
|
EOF
|
||||||
|
test_expect_equal_file EXPECTED OUTPUT
|
||||||
|
|
||||||
|
case $config in
|
||||||
|
XDG*)
|
||||||
|
test_begin_subtest "Set shadowed config value in database ($config)"
|
||||||
|
test_subtest_known_broken
|
||||||
|
name=${RANDOM}
|
||||||
|
value=${RANDOM}
|
||||||
|
key=test${test_count}.${name}
|
||||||
|
notmuch config set --database ${key} ${value}
|
||||||
|
notmuch config set ${key} shadow${value}
|
||||||
|
output=$(notmuch --config='' config get ${key})
|
||||||
|
notmuch config set --database ${key}
|
||||||
|
output2=$(notmuch --config='' config get ${key})
|
||||||
|
notmuch config set ${key}
|
||||||
|
test_expect_equal "${output}+${output2}" "${value}+"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
restore_config
|
restore_config
|
||||||
|
rm -rf home/.local
|
||||||
|
rm -rf home/.config
|
||||||
done
|
done
|
||||||
|
|
||||||
test_done
|
test_done
|
||||||
|
|
Loading…
Reference in a new issue