diff --git a/app/include/plasp-app/commands/CommandVersion.h b/app/include/plasp-app/commands/CommandVersion.h new file mode 100644 index 0000000..8b4c615 --- /dev/null +++ b/app/include/plasp-app/commands/CommandVersion.h @@ -0,0 +1,23 @@ +#ifndef __PLASP_APP__COMMANDS__COMMAND_VERSION_H +#define __PLASP_APP__COMMANDS__COMMAND_VERSION_H + +#include +#include + +//////////////////////////////////////////////////////////////////////////////////////////////////// +// +// Command Version +// +//////////////////////////////////////////////////////////////////////////////////////////////////// + +class CommandVersion : public Command<> +{ + public: + CommandVersion(); + + int run(int argc, char **argv); +}; + +//////////////////////////////////////////////////////////////////////////////////////////////////// + +#endif diff --git a/app/src/plasp-app/commands/CommandVersion.cpp b/app/src/plasp-app/commands/CommandVersion.cpp new file mode 100644 index 0000000..7b9a52b --- /dev/null +++ b/app/src/plasp-app/commands/CommandVersion.cpp @@ -0,0 +1,21 @@ +#include + +//////////////////////////////////////////////////////////////////////////////////////////////////// +// +// Command Version +// +//////////////////////////////////////////////////////////////////////////////////////////////////// + +CommandVersion::CommandVersion() +: Command(cxxopts::Options("plasp version", "Display version information.")) +{ +} + +//////////////////////////////////////////////////////////////////////////////////////////////////// + +int CommandVersion::run(int, char **) +{ + printVersion(); + + return EXIT_SUCCESS; +} diff --git a/app/src/plasp-app/main.cpp b/app/src/plasp-app/main.cpp index bca0ed2..03187a3 100644 --- a/app/src/plasp-app/main.cpp +++ b/app/src/plasp-app/main.cpp @@ -10,6 +10,7 @@ #include #include #include +#include //////////////////////////////////////////////////////////////////////////////////////////////////// // @@ -71,12 +72,6 @@ int main(int argc, char **argv) << "Usage: plasp []" << std::endl; }; - const auto printVersion = - [&]() - { - std::cout << Version << std::endl; - }; - colorlog::Logger logger; if (argc < 2) @@ -93,7 +88,7 @@ int main(int argc, char **argv) printHelp(); return EXIT_SUCCESS; case CommandType::Version: - printVersion(); + return CommandVersion().run(argc - 1, &argv[1]); return EXIT_SUCCESS; case CommandType::Translate: return CommandTranslate().run(argc - 1, &argv[1]);