mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 12:38:12 +00:00
config: Add option to remove config key
This commit is contained in:
parent
292398b585
commit
06cb526feb
2 changed files with 9 additions and 1 deletions
|
@ -5,7 +5,7 @@ config
|
||||||
## Synopsis
|
## Synopsis
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
$ config <domain> <group> <key> [value]
|
$ config [--remove] <domain> <group> <key> [value]
|
||||||
```
|
```
|
||||||
|
|
||||||
## Description
|
## Description
|
||||||
|
@ -16,6 +16,7 @@ Show or modify values in the configuration files through ConfigServer.
|
||||||
|
|
||||||
* `--help`: Display help message and exit
|
* `--help`: Display help message and exit
|
||||||
* `--version`: Print version
|
* `--version`: Print version
|
||||||
|
* `-r`, `--remove`: Remove key
|
||||||
|
|
||||||
## Arguments:
|
## Arguments:
|
||||||
|
|
||||||
|
|
|
@ -15,15 +15,22 @@ int main(int argc, char** argv)
|
||||||
String group;
|
String group;
|
||||||
String key;
|
String key;
|
||||||
String value_to_write;
|
String value_to_write;
|
||||||
|
bool remove_key = false;
|
||||||
|
|
||||||
Core::ArgsParser args_parser;
|
Core::ArgsParser args_parser;
|
||||||
args_parser.set_general_help("Show or modify values in the configuration files through ConfigServer.");
|
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(domain, "Config domain", "domain");
|
||||||
args_parser.add_positional_argument(group, "Group name", "group");
|
args_parser.add_positional_argument(group, "Group name", "group");
|
||||||
args_parser.add_positional_argument(key, "Key name", "key");
|
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.add_positional_argument(value_to_write, "Value to write", "value", Core::ArgsParser::Required::No);
|
||||||
args_parser.parse(argc, argv);
|
args_parser.parse(argc, argv);
|
||||||
|
|
||||||
|
if (remove_key) {
|
||||||
|
Config::remove_key(domain, group, key);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (!value_to_write.is_empty()) {
|
if (!value_to_write.is_empty()) {
|
||||||
Config::write_string(domain, group, key, value_to_write);
|
Config::write_string(domain, group, key, value_to_write);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue