Add --simple-version command line option.

This option automaticaly implies --nobanner as well as displays nothing else but the version.
This commit is contained in:
Pentarctagon 2021-11-16 17:04:08 -06:00
parent ff3ae6f685
commit ebac7ccddc
No known key found for this signature in database
GPG key ID: 9456BC54A21DBFA0
4 changed files with 19 additions and 1 deletions

View file

@ -417,6 +417,9 @@ assumes that the cache is valid. (dangerous)
.B -v, --version
shows the version number and exits.
.TP
.B -v, --version
shows the version number and nothing else, then exits.
.TP
.B -w, --windowed
runs the game in windowed mode.
.TP

View file

@ -161,6 +161,7 @@ commandline_options::commandline_options(const std::vector<std::string>& args)
, diff_left()
, diff_right()
, version(false)
, simple_version(false)
, report(false)
, windowed(false)
, with_replay(false)
@ -221,6 +222,7 @@ commandline_options::commandline_options(const std::vector<std::string>& args)
("username", po::value<std::string>(), "uses <username> when connecting to a server, ignoring other preferences.")
("validcache", "assumes that the cache is valid. (dangerous)")
("version,v", "prints the game's version number and exits.")
("simple-version", "prints the game's version number and nothing else.")
("with-replay", "replays the file loaded with the --load option.")
#ifdef _WIN32
("wconsole", "attaches a console window on startup (Windows only). Implied by any option that prints something and exits.")
@ -528,9 +530,14 @@ commandline_options::commandline_options(const std::vector<std::string>& args)
validate_schema = vm["validate-schema"].as<std::string>();
// If you add a new validate-* option, remember the any_validation_option() function
if (vm.count("use-schema"))
validate_with = vm["use-schema"].as<std::string>();;
validate_with = vm["use-schema"].as<std::string>();
if (vm.count("version"))
version = true;
if (vm.count("simple-version"))
{
simple_version = true;
nobanner = true;
}
if (vm.count("windowed"))
windowed = true;
if (vm.count("with-replay"))

View file

@ -237,6 +237,8 @@ public:
std::string diff_left, diff_right;
/** True if --version was given on the command line. Prints version and exits. */
bool version;
/** True if --simple-version was given on the command line. Prints version and nothing else then exits. */
bool simple_version;
/** True if --report was given on the command line. Prints a bug report-style info dump and exits. */
bool report;
/** True if --windowed was given on the command line. Starts Wesnoth in windowed mode. */

View file

@ -508,6 +508,12 @@ static int process_command_args(const commandline_options& cmdline_opts)
return 0;
}
if(cmdline_opts.simple_version) {
std::cout << game_config::wesnoth_version.str() << "\n";
return 0;
}
if(cmdline_opts.report) {
std::cout << "\n========= BUILD INFORMATION =========\n\n" << game_config::full_build_report();
return 0;