Skip to content

Commit

Permalink
bmpflash: Marked the version and help options exclusive, removing the…
Browse files Browse the repository at this point in the history
… need for the explicit either-or check
  • Loading branch information
dragonmux committed Jan 7, 2024
1 parent 33192d1 commit 484c188
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 11 deletions.
11 changes: 2 additions & 9 deletions src/bmpflash.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,7 @@ int main(const int argCount, const char *const *const argList)
console.showDebug(verbosity & 1U);

// Handle the version and help options first
const auto *const version{args["version"sv]};
const auto *const help{args["help"sv]};
if (version && help)
{
console.error("Can only specify one of --help and --version, not both."sv);
return 1;
}
if (version)
if (args["version"sv])
{
bmpflash::displayVersion();
const auto *const libusbVersion{libusb_get_version()};
Expand All @@ -92,7 +85,7 @@ int main(const int argCount, const char *const *const argList)
return 0;
}
// Display the help if requested or there were no command line options given
if (help || args.count() == 0U)
if (args["help"sv] || args.count() == 0U)
{
bmpflash::displayHelp();
return 0;
Expand Down
4 changes: 2 additions & 2 deletions src/include/options.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ namespace bmpflash
{
options
(
option_t{optionFlagPair_t{"-h"sv, "--help"sv}, "Display this help message and exit"sv},
option_t{"--version"sv, "Display the program version information and exit"sv},
option_t{optionFlagPair_t{"-h"sv, "--help"sv}, "Display this help message and exit"sv}.exclusive(),
option_t{"--version"sv, "Display the program version information and exit"sv}.exclusive(),
option_t{optionFlagPair_t{"-v"sv, "--verbosity"sv}, "Set the program output verbosity"sv}
.takesParameter(optionValueType_t::unsignedInt).valueRange(0U, 1U),
optionSet_t{"action"sv, actions}
Expand Down

0 comments on commit 484c188

Please sign in to comment.