Skip to content
Snippets Groups Projects
Commit ff9c308e authored by Wuttke, Joachim's avatar Wuttke, Joachim Committed by Wuttke, Joachim
Browse files

AppOptions: exit after -h or -v

parent 7a37f981
No related branches found
No related tags found
1 merge request!705GUI/App/main, file paths: various improvements
...@@ -48,7 +48,8 @@ bool isValid(const QSize& win_size) ...@@ -48,7 +48,8 @@ bool isValid(const QSize& win_size)
ApplicationOptions::ApplicationOptions(int argc, char** argv) ApplicationOptions::ApplicationOptions(int argc, char** argv)
: m_options_is_consistent(false) : m_options_is_consistent(false)
{ {
m_options.add_options()("help,h", "print help message"); m_options.add_options()("help,h", "print help message and exit");
m_options.add_options()("version,v", "print version and exit");
m_options.add_options()("with-debug", "run application with debug printout"); m_options.add_options()("with-debug", "run application with debug printout");
m_options.add_options()(geometry, bpo::value<std::string>(), m_options.add_options()(geometry, bpo::value<std::string>(),
"Main window geometry, e.g. 1600x1000"); "Main window geometry, e.g. 1600x1000");
...@@ -68,7 +69,7 @@ const bpo::variable_value& ApplicationOptions::operator[](const std::string& s) ...@@ -68,7 +69,7 @@ const bpo::variable_value& ApplicationOptions::operator[](const std::string& s)
bool ApplicationOptions::find(std::string name) const bool ApplicationOptions::find(std::string name) const
{ {
return (m_variables_map.count(name)); return m_variables_map.count(name);
} }
bool ApplicationOptions::isConsistent() const bool ApplicationOptions::isConsistent() const
...@@ -117,14 +118,15 @@ boost::program_options::options_description& ApplicationOptions::getOptions() ...@@ -117,14 +118,15 @@ boost::program_options::options_description& ApplicationOptions::getOptions()
void ApplicationOptions::processOptions() void ApplicationOptions::processOptions()
{ {
if (m_variables_map.count("help")) { if (m_variables_map.count("help")) {
printHelpMessage(); std::cout << "BornAgain Graphical User Interface" << std::endl;
m_options_is_consistent = false; std::cout << m_options << std::endl;
exit(0);
} }
else if (m_variables_map.count("version")) { else if (m_variables_map.count("version")) {
std::cout << "BornAgain-" << GUI::Util::Path::getBornAgainVersionString().toStdString() std::cout << "BornAgain-" << GUI::Util::Path::getBornAgainVersionString().toStdString()
<< std::endl; << std::endl;
m_options_is_consistent = false; exit(0);
} }
else if (m_variables_map.count(geometry)) { else if (m_variables_map.count(geometry)) {
...@@ -135,12 +137,6 @@ void ApplicationOptions::processOptions() ...@@ -135,12 +137,6 @@ void ApplicationOptions::processOptions()
} }
} }
void ApplicationOptions::printHelpMessage() const
{
std::cout << "BornAgain Graphical User Interface" << std::endl;
std::cout << m_options << std::endl;
}
QSize ApplicationOptions::mainWindowSize() const QSize ApplicationOptions::mainWindowSize() const
{ {
QString size_str = QString::fromStdString(m_variables_map[geometry].as<std::string>()); QString size_str = QString::fromStdString(m_variables_map[geometry].as<std::string>());
......
...@@ -46,8 +46,6 @@ public: ...@@ -46,8 +46,6 @@ public:
bool find(std::string name) const; bool find(std::string name) const;
private: private:
void printHelpMessage() const;
//! Parses command line arguments //! Parses command line arguments
void parseCommandLine(int argc, char** argv); void parseCommandLine(int argc, char** argv);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment