From cde892c77189d310d51e33ccc39fafb7f726a6f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20L=C3=BChne?= Date: Fri, 13 Oct 2017 18:28:33 +0200 Subject: [PATCH] Added command for printing version information. --- .../plasp-app/commands/CommandVersion.h | 23 +++++++++++++++++++ app/src/plasp-app/commands/CommandVersion.cpp | 21 +++++++++++++++++ app/src/plasp-app/main.cpp | 9 ++------ 3 files changed, 46 insertions(+), 7 deletions(-) create mode 100644 app/include/plasp-app/commands/CommandVersion.h create mode 100644 app/src/plasp-app/commands/CommandVersion.cpp 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]);