diff options
author | Ralf Donau <ruelle@volleyballschlaeger.de> | 2021-08-26 10:24:14 +0200 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2021-08-28 08:24:48 +0100 |
commit | e36931fffe994c7658d54f8c6b82d444a257bcf9 (patch) | |
tree | a39b671dbfea95ee677e72159ffcf5e53d046568 /Userland/Utilities/config.cpp | |
parent | 2dea772d48f45a5856eff39e14d615610b3c97c7 (diff) | |
download | serenity-e36931fffe994c7658d54f8c6b82d444a257bcf9.zip |
Utilities: Add a command line client for ConfigServer
This is an alternative to the ini utility which accesses the
configuration files through the newly introduced ConfigServer.
Diffstat (limited to 'Userland/Utilities/config.cpp')
-rw-r--r-- | Userland/Utilities/config.cpp | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/Userland/Utilities/config.cpp b/Userland/Utilities/config.cpp new file mode 100644 index 0000000000..14e31a559f --- /dev/null +++ b/Userland/Utilities/config.cpp @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2021, the SerenityOS developers. + * + * SPDX-License-Identifier: BSD-2-Clause + */ + +#include <LibConfig/Client.h> +#include <LibCore/ArgsParser.h> +#include <LibCore/EventLoop.h> + +int main(int argc, char** argv) +{ + Core::EventLoop loop; + String domain; + String group; + String key; + String value_to_write; + + Core::ArgsParser args_parser; + args_parser.set_general_help("Show or modify values in the configuration files through ConfigServer."); + 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 (!value_to_write.is_empty()) { + Config::write_string(domain, group, key, value_to_write); + return 0; + } + + auto value = Config::read_string(domain, group, key); + outln("{}", value); + + return 0; +} |