Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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();
Expand Down Expand Up @@ -81,7 +91,12 @@ bool application::initialize_impl(int argc, char** argv, vector<abstract_plugin*
bpo::store(bpo::parse_command_line(argc, argv, my->_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;
}

Expand Down
10 changes: 10 additions & 0 deletions include/appbase/application.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down