diff --git a/application.cpp b/application.cpp index 93e900dc8..369872527 100644 --- a/application.cpp +++ b/application.cpp @@ -22,7 +22,9 @@ class application_impl { options_description _app_options; options_description _cfg_options; - bfs::path _data_dir; + bfs::path _data_dir; + + string _version; }; application::application() @@ -32,6 +34,14 @@ application::application() application::~application() { } +void application::set_version(string version) { + my->_version = version; +} + +string application::version() const { + return my->_version; +} + void application::startup() { for (auto plugin : initialized_plugins) plugin->startup(); @@ -81,7 +91,12 @@ bool application::initialize_impl(int argc, char** argv, vector_app_options), options); if( options.count( "help" ) ) { - cout << my->_app_options << "\n"; + cout << my->_app_options << std::endl; + return false; + } + + if( options.count( "version" ) ) { + cout << my->_version << std::endl; return false; } diff --git a/include/appbase/application.hpp b/include/appbase/application.hpp index 985a608a4..e857de015 100644 --- a/include/appbase/application.hpp +++ b/include/appbase/application.hpp @@ -13,6 +13,16 @@ namespace appbase { public: ~application(); + /** @brief Sets version string + * + * @param version Version string output verbatim with -v/--version + */ + void set_version(string version); + /** @brief Gets version string + * + * @return Version string output with -v/--version + */ + string version() const; /** * @brief Looks for the --plugin commandline / config option and calls initialize on those plugins *