diff options
| author | isanae <14251494+isanae@users.noreply.github.com> | 2020-07-18 02:24:44 -0400 |
|---|---|---|
| committer | isanae <14251494+isanae@users.noreply.github.com> | 2020-11-03 11:39:01 -0500 |
| commit | 5e528fb4cf16ae208944d15d568c9140e3d741e4 (patch) | |
| tree | 8fd4927aeffb19406e2356d39c2bec0751c7f53d /src/commandline.h | |
| parent | b103f297752b170ee4ade6e0e9085c6d31c020ca (diff) | |
new CommandLine class
implemented crashdump as a command, fixed dump_running_process.bat to use it
attach to console if present instead of always create one
Diffstat (limited to 'src/commandline.h')
| -rw-r--r-- | src/commandline.h | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/src/commandline.h b/src/commandline.h new file mode 100644 index 00000000..d5ad5a32 --- /dev/null +++ b/src/commandline.h @@ -0,0 +1,62 @@ +#pragma once + +#include <vector> +#include <memory> + +namespace cl +{ + +namespace po = boost::program_options; + + +class Command +{ +public: + virtual ~Command() = default; + + std::string name() const; + std::string description() const; + + po::options_description options() const; + std::string usage() const; + + int run(po::variables_map& vm); + +protected: + struct Meta + { + std::string name, description; + }; + + virtual po::options_description doOptions() const; + virtual Meta meta() const = 0; + virtual int doRun(po::variables_map& vm) = 0; +}; + + +class CrashDumpCommand : public Command +{ +protected: + po::options_description doOptions() const; + Meta meta() const override; + int doRun(po::variables_map& vm) override; +}; + + +class CommandLine +{ +public: + CommandLine(); + + int run(int argc, char** argv); + std::string usage(const Command* c=nullptr) const; + +private: + po::options_description m_visibleOptions, m_allOptions; + po::positional_options_description m_positional; + std::vector<std::unique_ptr<Command>> m_commands; + + void createOptions(); +}; + +} // namespace |
