mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-10 18:10:56 +09:00
LibCore: Add --version flag to ArgsParser
`--version` always prints "git" for now. The motivation is that the neofetch port calls `Shell --version` and adds the output to its output. And if `Shell --version` prints a long error message about it not knowing the flag, neofetch's output looks a bit ugly. Per Discord discussion, just add the flag to ArgsParser instead of only to Shell.
This commit is contained in:
parent
7d4addc6d3
commit
1f71d7bf22
Notes:
sideshowbarker
2024-07-18 06:53:34 +09:00
Author: https://github.com/nico
Commit: 1f71d7bf22
Pull-request: https://github.com/SerenityOS/serenity/pull/9417
Reviewed-by: https://github.com/alimpfard
2 changed files with 9 additions and 1 deletions
|
@ -28,6 +28,7 @@ namespace Core {
|
|||
ArgsParser::ArgsParser()
|
||||
{
|
||||
add_option(m_show_help, "Display this message", "help", 0);
|
||||
add_option(m_show_version, "Print version", "version", 0);
|
||||
}
|
||||
|
||||
bool ArgsParser::parse(int argc, char* const* argv, FailureBehavior failure_behavior)
|
||||
|
@ -153,7 +154,13 @@ bool ArgsParser::parse(int argc, char* const* argv, FailureBehavior failure_beha
|
|||
}
|
||||
|
||||
// We're done parsing! :)
|
||||
// Now let's show help if requested.
|
||||
// Now let's show version or help if requested.
|
||||
if (m_show_version) {
|
||||
outln(stdout, "git");
|
||||
if (failure_behavior == FailureBehavior::Exit || failure_behavior == FailureBehavior::PrintUsageAndExit)
|
||||
exit(0);
|
||||
return false;
|
||||
}
|
||||
if (m_show_help) {
|
||||
print_usage(stdout, argv[0]);
|
||||
if (failure_behavior == FailureBehavior::Exit || failure_behavior == FailureBehavior::PrintUsageAndExit)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue