mirror of
https://github.com/RGBCube/serenity
synced 2025-05-20 13:45:06 +00:00
ini: Use String for arguments
This commit is contained in:
parent
86d4b7ebfc
commit
69a896cb82
1 changed files with 6 additions and 6 deletions
|
@ -14,10 +14,10 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||||
{
|
{
|
||||||
TRY(Core::System::pledge("stdio rpath wpath cpath"));
|
TRY(Core::System::pledge("stdio rpath wpath cpath"));
|
||||||
|
|
||||||
char const* path = nullptr;
|
StringView path;
|
||||||
char const* group = nullptr;
|
String group;
|
||||||
char const* key = nullptr;
|
String key;
|
||||||
char const* value_to_write = nullptr;
|
String value_to_write;
|
||||||
|
|
||||||
Core::ArgsParser args_parser;
|
Core::ArgsParser args_parser;
|
||||||
args_parser.add_positional_argument(path, "Path to INI file", "path");
|
args_parser.add_positional_argument(path, "Path to INI file", "path");
|
||||||
|
@ -31,9 +31,9 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto config = TRY(Core::ConfigFile::open(path, value_to_write ? Core::ConfigFile::AllowWriting::Yes : Core::ConfigFile::AllowWriting::No));
|
auto config = TRY(Core::ConfigFile::open(path, value_to_write.is_null() ? Core::ConfigFile::AllowWriting::No : Core::ConfigFile::AllowWriting::Yes));
|
||||||
|
|
||||||
if (value_to_write) {
|
if (!value_to_write.is_null()) {
|
||||||
config->write_entry(group, key, value_to_write);
|
config->write_entry(group, key, value_to_write);
|
||||||
TRY(config->sync());
|
TRY(config->sync());
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue