Skip to content

Commit

Permalink
bmpflash: Implemented action help support for the tool
Browse files Browse the repository at this point in the history
  • Loading branch information
dragonmux committed Oct 13, 2024
1 parent 8a41762 commit 80be198
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/bmpflash.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,20 @@ namespace bmpflash
console.writeln("This utility is licensed under BSD-3-Clause"sv);
console.writeln("Please report bugs to https://github.com/blackmagic-debug/bmpflash/issues"sv);
}

void displayActionHelp(const optionAlternation_t &action)
{
console.info("bmpflash - Black Magic Probe companion utility for SPI Flash provisioning and usage"sv);
console.writeln();
console.writeln("Usage:"sv);
console.writeln("\tbmpflash [options] "sv, action.displayName(), " [actionOptions]"sv);
console.writeln();
console.writeln("Action "sv, nullptr);
action.suboptions().displayHelp();
console.writeln();
console.writeln("This utility is licensed under BSD-3-Clause"sv);
console.writeln("Please report bugs to https://github.com/blackmagic-debug/bmpflash/issues"sv);
}
}

[[nodiscard]] auto findBMPs(const usbContext_t &context)
Expand Down Expand Up @@ -108,6 +122,18 @@ int main(const int argCount, const char *const *const argList)
}
const auto &action{std::get<choice_t>(*actionArg)};

// Check if `-h`/`--help` was given for this action
if (action.arguments()["help"sv])
{
// It was, so find the right action option set and display its help
for (const auto &actionOptions : bmpflash::actions)
{
if (actionOptions.matches(action.value()))
bmpflash::displayActionHelp(actionOptions);
}
return 0;
}

// Get a libusb context to perform everything in
const usbContext_t context{};
if (!context.valid())
Expand Down

0 comments on commit 80be198

Please sign in to comment.