summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfaxe1008 <fabianblatz@gmail.com>2021-11-13 15:05:53 +0100
committerAndreas Kling <kling@serenityos.org>2021-11-14 22:42:52 +0100
commit06cb526feb8e643970ddf4b11f2cc077009d090e (patch)
tree61195f0616b212d4782e9faf42f93ba049bf695c
parent292398b5857d0104f7c33fdb5d79f45fe8b395dd (diff)
downloadserenity-06cb526feb8e643970ddf4b11f2cc077009d090e.zip
config: Add option to remove config key
-rw-r--r--Base/usr/share/man/man1/config.md3
-rw-r--r--Userland/Utilities/config.cpp7
2 files changed, 9 insertions, 1 deletions
diff --git a/Base/usr/share/man/man1/config.md b/Base/usr/share/man/man1/config.md
index 7ff2729ae6..4386d6b714 100644
--- a/Base/usr/share/man/man1/config.md
+++ b/Base/usr/share/man/man1/config.md
@@ -5,7 +5,7 @@ config
## Synopsis
```sh
-$ config <domain> <group> <key> [value]
+$ config [--remove] <domain> <group> <key> [value]
```
## Description
@@ -16,6 +16,7 @@ Show or modify values in the configuration files through ConfigServer.
* `--help`: Display help message and exit
* `--version`: Print version
+* `-r`, `--remove`: Remove key
## Arguments:
diff --git a/Userland/Utilities/config.cpp b/Userland/Utilities/config.cpp
index 880a06b46d..881c6e9035 100644
--- a/Userland/Utilities/config.cpp
+++ b/Userland/Utilities/config.cpp
@@ -15,15 +15,22 @@ int main(int argc, char** argv)
String group;
String key;
String value_to_write;
+ bool remove_key = false;
Core::ArgsParser args_parser;
args_parser.set_general_help("Show or modify values in the configuration files through ConfigServer.");
+ args_parser.add_option(remove_key, "Remove key", "remove", 'r');
args_parser.add_positional_argument(domain, "Config domain", "domain");
args_parser.add_positional_argument(group, "Group name", "group");
args_parser.add_positional_argument(key, "Key name", "key");
args_parser.add_positional_argument(value_to_write, "Value to write", "value", Core::ArgsParser::Required::No);
args_parser.parse(argc, argv);
+ if (remove_key) {
+ Config::remove_key(domain, group, key);
+ return 0;
+ }
+
if (!value_to_write.is_empty()) {
Config::write_string(domain, group, key, value_to_write);
return 0;