Skip to content

Commit

Permalink
Config CLI: Handle missing config values correctly
Browse files Browse the repository at this point in the history
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.`
  • Loading branch information
mustafaquraish authored and awesomekling committed Aug 31, 2021
1 parent 8e90a4f commit b0bd4be
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions Userland/Utilities/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

0 comments on commit b0bd4be

Please sign in to comment.