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.
This commit is contained in:
parent
2dea772d48
commit
e36931fffe
Notes:
sideshowbarker
2024-07-18 05:11:01 +09:00
Author: https://github.com/doctor-rd Commit: https://github.com/SerenityOS/serenity/commit/e36931fffe9 Pull-request: https://github.com/SerenityOS/serenity/pull/9612 Reviewed-by: https://github.com/TobyAsE
2 changed files with 37 additions and 0 deletions
|
@ -57,6 +57,7 @@ target_link_libraries(bt LibSymbolication)
|
|||
target_link_libraries(checksum LibCrypto)
|
||||
target_link_libraries(chres LibGUI)
|
||||
target_link_libraries(cksum LibCrypto)
|
||||
target_link_libraries(config LibConfig)
|
||||
target_link_libraries(copy LibGUI)
|
||||
target_link_libraries(crash LibTest)
|
||||
target_link_libraries(disasm LibX86)
|
||||
|
|
36
Userland/Utilities/config.cpp
Normal file
36
Userland/Utilities/config.cpp
Normal file
|
@ -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;
|
||||
}
|
Loading…
Add table
Reference in a new issue