Added command for printing version information.

This commit is contained in:
Patrick Lühne 2017-10-13 18:28:33 +02:00
parent 974c94fbb0
commit cde892c771
Signed by: patrick
GPG Key ID: 05F3611E97A70ABF
3 changed files with 46 additions and 7 deletions

View File

@ -0,0 +1,23 @@
#ifndef __PLASP_APP__COMMANDS__COMMAND_VERSION_H
#define __PLASP_APP__COMMANDS__COMMAND_VERSION_H
#include <plasp-app/Command.h>
#include <plasp-app/OptionGroups.h>
////////////////////////////////////////////////////////////////////////////////////////////////////
//
// Command Version
//
////////////////////////////////////////////////////////////////////////////////////////////////////
class CommandVersion : public Command<>
{
public:
CommandVersion();
int run(int argc, char **argv);
};
////////////////////////////////////////////////////////////////////////////////////////////////////
#endif

View File

@ -0,0 +1,21 @@
#include <plasp-app/commands/CommandVersion.h>
////////////////////////////////////////////////////////////////////////////////////////////////////
//
// Command Version
//
////////////////////////////////////////////////////////////////////////////////////////////////////
CommandVersion::CommandVersion()
: Command(cxxopts::Options("plasp version", "Display version information."))
{
}
////////////////////////////////////////////////////////////////////////////////////////////////////
int CommandVersion::run(int, char **)
{
printVersion();
return EXIT_SUCCESS;
}

View File

@ -10,6 +10,7 @@
#include <plasp-app/Command.h> #include <plasp-app/Command.h>
#include <plasp-app/Version.h> #include <plasp-app/Version.h>
#include <plasp-app/commands/CommandTranslate.h> #include <plasp-app/commands/CommandTranslate.h>
#include <plasp-app/commands/CommandVersion.h>
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
// //
@ -71,12 +72,6 @@ int main(int argc, char **argv)
<< "Usage: plasp <command> [<arguments>]" << std::endl; << "Usage: plasp <command> [<arguments>]" << std::endl;
}; };
const auto printVersion =
[&]()
{
std::cout << Version << std::endl;
};
colorlog::Logger logger; colorlog::Logger logger;
if (argc < 2) if (argc < 2)
@ -93,7 +88,7 @@ int main(int argc, char **argv)
printHelp(); printHelp();
return EXIT_SUCCESS; return EXIT_SUCCESS;
case CommandType::Version: case CommandType::Version:
printVersion(); return CommandVersion().run(argc - 1, &argv[1]);
return EXIT_SUCCESS; return EXIT_SUCCESS;
case CommandType::Translate: case CommandType::Translate:
return CommandTranslate().run(argc - 1, &argv[1]); return CommandTranslate().run(argc - 1, &argv[1]);