Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add --mir-version command line option. solves MirServer/mir#3058 #3130

Merged
merged 7 commits into from
Nov 17, 2023
10 changes: 10 additions & 0 deletions src/platform/options/default_configuration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,8 @@ void mo::DefaultConfiguration::parse_arguments(
{
desc.add_options()
("help,h", "this help text");
desc.add_options()
("version,V", "display Mir version and exit");

options.parse_arguments(desc, argc, argv);

Expand All @@ -304,12 +306,20 @@ void mo::DefaultConfiguration::parse_arguments(
tokens.push_back(token.c_str());
if (!tokens.empty()) unparsed_arguments_handler(tokens.size(), tokens.data());

// See the ExitWithOutput documentation for information about its usage.
if (options.is_set("help"))
{
std::ostringstream help_text;
help_text << desc;
BOOST_THROW_EXCEPTION(mir::ExitWithOutput(help_text.str()));
}

if (options.is_set("version"))
{
std::ostringstream mir_version;
mir_version << MIR_VERSION_MAJOR << "." << MIR_VERSION_MINOR << "." << MIR_VERSION_MICRO << std::endl;
BOOST_THROW_EXCEPTION(mir::ExitWithOutput(mir_version.str()));
}
}
catch (po::error const& error)
{
Expand Down