1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-14 09:34:59 +00:00

Config CLI: Handle missing config values correctly

If the domain/group/key doesn't exist in the config, exit with
non-zero status and don't print out anything.

Previously the CLI would print a single empty line if the config
value was not found with LibConfig. Now, we use the proper
`Config::Client::the().read_string()` API which can return an
`Optional` type indicating failure.`
This commit is contained in:
Mustafa Quraish 2021-08-28 10:10:41 -04:00 committed by Andreas Kling
parent 8e90a4fd1c
commit b0bd4be59a

View file

@ -29,8 +29,9 @@ int main(int argc, char** argv)
return 0;
}
auto value = Config::read_string(domain, group, key);
outln("{}", value);
auto value_or_error = Config::Client::the().read_string_value(domain, group, key);
if (!value_or_error.has_value())
return 1;
outln("{}", value_or_error.value());
return 0;
}