diff options
author | Jack Lloyd <[email protected]> | 2017-10-24 14:38:09 -0400 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2017-10-24 14:38:09 -0400 |
commit | 39314a242f1a98d7493410ebddd449fa57813bc2 (patch) | |
tree | 09ec1e886102b9ec38d80066e5fc2c416a3a46d3 /src/cli/utils.cpp | |
parent | c2830ddf08b41a9f5f2a472e0cc488c9c358fdb2 (diff) |
Tweak help output a bit
Diffstat (limited to 'src/cli/utils.cpp')
-rw-r--r-- | src/cli/utils.cpp | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/cli/utils.cpp b/src/cli/utils.cpp index 1e2ddf42e..602035c8c 100644 --- a/src/cli/utils.cpp +++ b/src/cli/utils.cpp @@ -14,6 +14,7 @@ #include <botan/cpuid.h> #include <botan/hex.h> #include <botan/parsing.h> +#include <sstream> #if defined(BOTAN_HAS_BASE64_CODEC) #include <botan/base64.h> @@ -29,6 +30,37 @@ namespace Botan_CLI { +class Print_Help final : public Command + { + public: + Print_Help() : Command("help") {} + + std::string help_text() const override + { + std::ostringstream oss; + + oss << "Usage: botan <cmd> <cmd-options>\n\n"; + oss << "All commands support --verbose --help --output= --error-output= --rng-type= --drbg-seed=\n\n"; + oss << "Available commands:\n"; + + for(const auto& cmd_name : Command::registered_cmds()) + { + std::unique_ptr<Command> cmd = Command::get_cmd(cmd_name); + oss << " " << cmd->cmd_spec() << "\n"; + } + + return oss.str(); + } + + void go() override + { + this->set_return_code(1); + output() << help_text(); + } + }; + +BOTAN_REGISTER_COMMAND("help", Print_Help); + class Config_Info final : public Command { public: |