23 #include <boost/any.hpp>
24 #include <boost/program_options/cmdline.hpp>
25 #include <boost/program_options/errors.hpp>
26 #include <boost/program_options/parsers.hpp>
27 #include <boost/program_options/positional_options.hpp>
28 #include <boost/program_options/value_semantic.hpp>
29 #include <boost/program_options/variables_map.hpp>
34 namespace po = boost::program_options;
36 class two_strings :
public std::pair<std::string,std::string> {};
38 static void validate(boost::any& v,
const std::vector<std::string>& values,
42 if(values.size() != 2) {
43 throw po::validation_error(po::validation_error::invalid_option_value);
45 ret_val.first = values[0];
46 ret_val.second = values[1];
51 : error(
formatter() <<
"Invalid resolution \"" << resolution
52 <<
"\" (WIDTHxHEIGHT expected)")
57 const std::string& expected_format)
58 : error(
formatter() <<
"Invalid value set \"" << str
59 <<
"\" (" << expected_format <<
" expected)")
64 #define IMPLY_TERMINAL " Implies --no-log-to-file"
69 , campaign_difficulty()
71 , campaign_skip_story(false)
80 #ifdef DEBUG_WINDOW_LAYOUT_GRAPHS
92 , log_precise_timestamps(false)
94 , multiplayer_ai_config()
95 , multiplayer_algorithm()
96 , multiplayer_controller()
98 , multiplayer_exit_at_end()
99 , multiplayer_ignore_map_settings()
100 , multiplayer_label()
102 , multiplayer_repeat()
103 , multiplayer_scenario()
105 , multiplayer_turns()
115 , preprocess_defines()
116 , preprocess_input_macros()
117 , preprocess_output_macros()
119 , preprocess_target()
127 , generate_spritesheet()
129 , screenshot_map_file()
130 , screenshot_output_file()
133 , script_unsafe_mode(false)
134 , strict_validation(false)
137 , headless_unit_test(false)
138 , noreplaycheck(false)
140 , usercache_path(false)
142 , userdata_path(false)
145 , validate_core(false)
155 , simple_version(false)
162 , no_log_sanitize(false)
164 , no_log_to_file(false)
165 , translation_percent()
166 , args_(args.begin() + 1, args.end())
167 , args0_(*args.begin())
174 po::options_description general_opts(
"General options");
175 general_opts.add_options()
176 (
"all-translations",
"Show all translations, even incomplete ones.")
177 (
"clock",
"Adds the option to show a clock for testing the drawing timer.")
178 (
"core", po::value<std::string>(),
"overrides the loaded core with the one whose id is specified.")
179 (
"data-dir", po::value<std::string>(),
"overrides the data directory with the one specified.")
180 (
"data-path",
"prints the path of the data directory and exits." IMPLY_TERMINAL)
181 (
"debug,d",
"enables additional command mode options in-game.")
182 (
"debug-lua",
"enables some Lua debugging mechanisms")
183 (
"strict-lua",
"disallow deprecated Lua API calls")
184 (
"allow-insecure",
"Allows sending a plaintext password over an unencrypted connection. Should only ever be used for local testing.")
185 #ifdef DEBUG_WINDOW_LAYOUT_GRAPHS
186 (
"debug-dot-level", po::value<std::string>(),
"sets the level of the debug dot files. <arg> should be a comma separated list of levels. These files are used for debugging the widgets especially the for the layout engine. When enabled the engine will produce dot files which can be converted to images with the dot tool. Available levels: size (generate the size info of the widget), state (generate the state info of the widget).")
187 (
"debug-dot-domain", po::value<std::string>(),
"sets the domain of the debug dot files. <arg> should be a comma separated list of domains. See --debug-dot-level for more info. Available domains: show (generate the data when the dialog is about to be shown), layout (generate the data during the layout phase - might result in multiple files). The data can also be generated when the F12 is pressed in a dialog.")
189 (
"editor,e", po::value<std::string>()->implicit_value(std::string()),
"starts the in-game map editor directly. If file <arg> is specified, equivalent to -e --load <arg>.")
191 (
"language,L", po::value<std::string>(),
"uses language <arg> (symbol) this session. Example: --language ang_GB@latin")
192 (
"load,l", po::value<std::string>(),
"loads the save <arg> from the standard save game directory. When launching the map editor via -e, the map <arg> is loaded, relative to the current directory. If it is a directory, the editor will start with a load map dialog opened there.")
193 (
"noaddons",
"disables the loading of all add-ons.")
194 (
"nocache",
"disables caching of game data.")
195 (
"nomusic",
"runs the game without music.")
196 (
"nosound",
"runs the game without sounds and music.")
197 (
"password", po::value<std::string>(),
"uses <password> when connecting to a server, ignoring other preferences.")
198 (
"plugin", po::value<std::string>(),
"(experimental) load a script which defines a wesnoth plugin. similar to --script below, but Lua file should return a function which will be run as a coroutine and periodically woken up with updates.")
199 (
"render-image", po::value<two_strings>()->multitoken(),
"takes two arguments: <image> <output>. Like screenshot, but instead of a map, takes a valid Wesnoth 'image path string' with image path functions, and writes it to a .png file." IMPLY_TERMINAL)
200 (
"generate-spritesheet", po::value<std::string>(),
"generates a spritesheet from all png images in the given path, recursively (one sheet per directory)")
201 (
"report,R",
"initializes game directories, prints build information suitable for use in bug reports, and exits." IMPLY_TERMINAL)
202 (
"rng-seed", po::value<unsigned int>(),
"seeds the random number generator with number <arg>. Example: --rng-seed 0")
203 (
"screenshot", po::value<two_strings>()->multitoken(),
"takes two arguments: <map> <output>. Saves a screenshot of <map> to <output> without initializing a screen. Editor must be compiled in for this to work." IMPLY_TERMINAL)
204 (
"script", po::value<std::string>(),
"(experimental) file containing a Lua script to control the client")
205 (
"server,s", po::value<std::string>()->implicit_value(std::string()),
"connects to the host <arg> if specified or to the first host in your preferences.")
206 (
"strict-validation",
"makes validation errors fatal")
207 (
"translations-over", po::value<unsigned int>(),
"Specify the standard for determining whether a translation is complete.")
208 (
"unsafe-scripts",
"makes the \'package\' package available to Lua scripts, so that they can load arbitrary packages. Do not do this with untrusted scripts! This action gives ua the same permissions as the Wesnoth executable.")
209 (
"usercache-dir", po::value<std::string>(),
"sets the path of the cache directory to $HOME/<arg> or My Documents\\My Games\\<arg> for Windows. You can specify also an absolute path outside the $HOME or My Documents\\My Games directory. Defaults to $HOME/.cache/wesnoth on X11 and to the userdata-dir on other systems.")
210 (
"usercache-path",
"prints the path of the cache directory and exits.")
211 (
"userdata-dir", po::value<std::string>(),
"sets the path of the userdata directory. You can use ~ to denote $HOME or My Documents\\My Games on Windows.")
212 (
"userdata-path",
"prints the path of the userdata directory and exits." IMPLY_TERMINAL)
213 (
"username", po::value<std::string>(),
"uses <username> when connecting to a server, ignoring other preferences.")
214 (
"validcache",
"assumes that the cache is valid. (dangerous)")
215 (
"version,v",
"prints the game's version number and exits." IMPLY_TERMINAL)
216 (
"simple-version",
"prints the game's version number and nothing else." IMPLY_TERMINAL)
217 (
"with-replay",
"replays the file loaded with the --load option.")
220 po::options_description campaign_opts(
"Campaign options");
221 campaign_opts.add_options()
222 (
"campaign,c", po::value<std::string>()->implicit_value(std::string()),
"goes directly to the campaign with id <arg>. A selection menu will appear if no id was specified.")
223 (
"campaign-difficulty", po::value<int>(),
"The difficulty of the specified campaign (1 to max). If none specified, the campaign difficulty selection widget will appear.")
224 (
"campaign-scenario", po::value<std::string>(),
"The id of the scenario from the specified campaign. The default is the first scenario.")
225 (
"campaign-skip-story",
"Skip [story] tags of the specified campaign.")
228 po::options_description display_opts(
"Display options");
229 display_opts.add_options()
230 (
"fps",
"displays the number of frames per second the game is currently running at, in a corner of the screen. Min/avg/max don't take the FPS limiter into account, act does.")
231 (
"fullscreen,f",
"runs the game in full screen mode.")
232 (
"max-fps", po::value<int>(),
"the maximum fps the game tries to run at. Values should be between 1 and 1000, the default is the display's refresh rate.")
233 (
"new-widgets",
"there is a new WIP widget toolkit this switch enables the new toolkit (VERY EXPERIMENTAL don't file bug reports since most are known). Parts of the library are deemed stable and will work without this switch.")
234 (
"resolution,r", po::value<std::string>(),
"sets the screen resolution. <arg> should have format XxY. Example: --resolution 800x600")
235 (
"windowed,w",
"runs the game in windowed mode.")
238 po::options_description logging_opts(
"Logging options");
239 logging_opts.add_options()
240 (
"logdomains", po::value<std::string>()->implicit_value(std::string()),
"lists defined log domains (only the ones containing <arg> filter if such is provided) and exits." IMPLY_TERMINAL)
241 (
"log-error", po::value<std::vector<std::string>>()->composing(),
"sets the severity level of the specified log domain(s) to 'error'. <arg> should be given as a comma-separated list of domains, wildcards are allowed. Example: --log-error=network,gui/*,engine/enemies")
242 (
"log-warning", po::value<std::vector<std::string>>()->composing(),
"sets the severity level of the specified log domain(s) to 'warning'. Similar to --log-error.")
243 (
"log-info", po::value<std::vector<std::string>>()->composing(),
"sets the severity level of the specified log domain(s) to 'info'. Similar to --log-error.")
244 (
"log-debug", po::value<std::vector<std::string>>()->composing(),
"sets the severity level of the specified log domain(s) to 'debug'. Similar to --log-error.")
245 (
"log-none", po::value<std::vector<std::string>>()->composing(),
"sets the severity level of the specified log domain(s) to 'none'. Similar to --log-error.")
246 (
"log-precise",
"shows the timestamps in log output with more precision.")
247 (
"no-log-to-file",
"log output is written only to standard error rather than to a file. The environment variable WESNOTH_NO_LOG_FILE can also be set as an alternative.")
248 (
"log-to-file",
"log output is written to the log file instead of standard error. Cancels the effect of --no-log-to-file whether implicit or explicit.")
249 (
"no-log-sanitize",
"disables the anonymization that's normally applied when logging, for example replacing usernames with USER.")
251 (
"wnoconsole",
"For Windows, when used with --no-log-to-file, results in output being written to cerr/cout instead of CONOUT. Otherwise, does nothing.")
255 po::options_description multiplayer_opts(
"Multiplayer options");
256 multiplayer_opts.add_options()
257 (
"multiplayer,m",
"Starts a multiplayer game. There are additional options that can be used as explained below:")
258 (
"ai-config", po::value<std::vector<std::string>>()->composing(),
"selects a configuration file to load for this side. <arg> should have format side:value")
259 (
"algorithm", po::value<std::vector<std::string>>()->composing(),
"selects a non-standard algorithm to be used by the AI controller for this side. <arg> should have format side:value")
260 (
"controller", po::value<std::vector<std::string>>()->composing(),
"selects the controller for this side. <arg> should have format side:value")
261 (
"era", po::value<std::string>(),
"selects the era to be played in by its id.")
262 (
"exit-at-end",
"exit Wesnoth at the end of the scenario.")
263 (
"ignore-map-settings",
"do not use map settings.")
264 (
"label", po::value<std::string>(),
"sets the label for AIs.")
265 (
"multiplayer-repeat", po::value<unsigned int>(),
"repeats a multiplayer game after it is finished <arg> times.")
267 (
"parm", po::value<std::vector<std::string>>()->composing(),
"sets additional parameters for this side. <arg> should have format side:name:value.")
268 (
"scenario", po::value<std::string>(),
"selects a multiplayer scenario. The default scenario is \"multiplayer_The_Freelands\".")
269 (
"side", po::value<std::vector<std::string>>()->composing(),
"selects a faction of the current era for this side by id. <arg> should have format side:value.")
270 (
"turns", po::value<std::string>(),
"sets the number of turns. By default no turn limit is set.")
273 po::options_description testing_opts(
"Testing options");
274 testing_opts.add_options()
275 (
"test,t", po::value<std::string>()->implicit_value(std::string()),
"runs the game in a small test scenario. If specified, scenario <arg> will be used instead.")
276 (
"unit,u", po::value<std::vector<std::string>>(),
"runs a unit test scenario. The GUI is not shown and the exit code of the program reflects the victory / defeat conditions of the scenario.\n\t0 - PASS\n\t1 - FAIL\n\t3 - FAIL (INVALID REPLAY)\n\t4 - FAIL (ERRORED REPLAY)\n\t5 - FAIL (BROKE STRICT)\n\t6 - FAIL (WML EXCEPTION)\n\tMultiple tests can be run by giving this option multiple times, in this case the test run will stop immediately after any test which doesn't PASS and the return code will be the status of the test that caused the stop." IMPLY_TERMINAL)
277 (
"showgui",
"don't run headlessly (for debugging a failing test)")
278 (
"log-strict", po::value<std::string>(),
"sets the strict level of the logger. any messages sent to log domains of this level or more severe will cause the unit test to fail regardless of the victory result.")
279 (
"nobanner",
"suppress startup banner.")
280 (
"noreplaycheck",
"don't try to validate replay of unit test.")
281 (
"mp-test",
"load the test mp scenarios.")
284 po::options_description parsing_opts(
"WML parsing options");
285 parsing_opts.add_options()
286 (
"use-schema,S", po::value<std::string>(),
"specify a schema to validate WML against (defaults to the core schema).")
287 (
"validate,V", po::value<std::string>(),
"validate a specified WML file against a schema." IMPLY_TERMINAL)
288 (
"validate-addon", po::value<std::string>()->value_name(
"addon_id"),
"validate the specified addon's WML against the schema. Requires the user to play the campaign (in the GUI) to trigger the validation.")
289 (
"validate-core",
"validate the core WML against the schema.")
290 (
"validate-schema", po::value<std::string>(),
"validate a specified WML schema." IMPLY_TERMINAL)
291 (
"diff,D", po::value<two_strings>()->multitoken(),
"diff two preprocessed WML documents." IMPLY_TERMINAL)
292 (
"output,o", po::value<std::string>(),
"output to specified file")
293 (
"patch,P", po::value<two_strings>()->multitoken(),
"apply a patch to a preprocessed WML document." IMPLY_TERMINAL)
294 (
"preprocess,p", po::value<two_strings>()->multitoken(),
"requires two arguments: <file/folder> <target directory>. Preprocesses a specified file/folder. The preprocessed file(s) will be written in the specified target directory: a plain cfg file and a processed cfg file." IMPLY_TERMINAL)
295 (
"preprocess-string", po::value<std::string>(),
"preprocess given string" IMPLY_TERMINAL)
296 (
"preprocess-defines", po::value<std::string>(),
"comma separated list of defines to be used by '--preprocess' command. If 'SKIP_CORE' is in the define list the data/core won't be preprocessed. Example: --preprocess-defines=FOO,BAR")
297 (
"preprocess-input-macros", po::value<std::string>(),
"used only by the '--preprocess' command. Specifies source file <arg> that contains [preproc_define]s to be included before preprocessing.")
298 (
"preprocess-output-macros", po::value<std::string>()->implicit_value(std::string()),
"used only by the '--preprocess' command. Will output all preprocessed macros in the target file <arg>. If the file is not specified the output will be file '_MACROS_.cfg' in the target directory of preprocess's command.")
304 visible_.add(general_opts).add(campaign_opts).add(display_opts).add(logging_opts).add(multiplayer_opts).add(testing_opts).add(parsing_opts);
308 po::positional_options_description positional;
309 positional.add(
"data-dir",1);
311 po::variables_map vm;
312 const int parsing_style = po::command_line_style::default_style ^ po::command_line_style::allow_guessing;
314 const auto parsed_options = po::command_line_parser(
args_)
316 .positional(positional)
317 .style(parsing_style)
320 po::store(parsed_options, vm);
322 if(vm.count(
"ai-config"))
324 if(vm.count(
"algorithm"))
326 if(vm.count(
"campaign"))
327 campaign = vm[
"campaign"].as<std::string>();
328 if(vm.count(
"campaign-difficulty"))
330 if(vm.count(
"campaign-scenario"))
332 if(vm.count(
"campaign-skip-story"))
334 if(vm.count(
"clock"))
337 core_id = vm[
"core"].as<std::string>();
338 if(vm.count(
"controller"))
340 if(vm.count(
"data-dir"))
341 data_dir = vm[
"data-dir"].as<std::string>();
342 if(vm.count(
"data-path"))
344 if(vm.count(
"debug"))
346 if(vm.count(
"debug-lua"))
348 if(vm.count(
"strict-lua"))
350 if(vm.count(
"allow-insecure"))
352 #ifdef DEBUG_WINDOW_LAYOUT_GRAPHS
353 if(vm.count(
"debug-dot-domain")) {
354 debug_dot_domain = vm[
"debug-dot-domain"].as<std::string>();
356 if(vm.count(
"debug-dot-level")) {
357 debug_dot_level = vm[
"debug-dot-level"].as<std::string>();
360 if(vm.count(
"editor"))
361 editor = vm[
"editor"].as<std::string>();
364 if(vm.count(
"exit-at-end"))
368 if(vm.count(
"fullscreen"))
372 if(vm.count(
"ignore-map-settings"))
374 if(vm.count(
"label"))
376 if(vm.count(
"language"))
377 language = vm[
"language"].as<std::string>();
379 load = vm[
"load"].as<std::string>();
380 if(vm.count(
"logdomains"))
381 logdomains = vm[
"logdomains"].as<std::string>();
382 if(vm.count(
"log-precise"))
384 if(vm.count(
"log-strict"))
386 if(vm.count(
"max-fps"))
387 max_fps = vm[
"max-fps"].as<int>();
388 if(vm.count(
"mp-test"))
390 if(vm.count(
"multiplayer"))
392 if(vm.count(
"multiplayer-repeat"))
394 if(vm.count(
"new-widgets"))
396 if(vm.count(
"noaddons"))
398 if(vm.count(
"nocache"))
400 if(vm.count(
"nomusic"))
402 if(vm.count(
"noreplaycheck"))
404 if(vm.count(
"nosound"))
406 if(vm.count(
"nogui"))
408 if(vm.count(
"nobanner"))
412 if(vm.count(
"preprocess"))
418 if(vm.count(
"preprocess-string"))
428 if(vm.count(
"patch"))
434 if(vm.count(
"output"))
438 if(vm.count(
"preprocess-defines"))
440 if(vm.count(
"preprocess-input-macros"))
442 if(vm.count(
"preprocess-output-macros"))
444 if(vm.count(
"resolution"))
446 if(vm.count(
"rng-seed"))
447 rng_seed = vm[
"rng-seed"].as<unsigned int>();
448 if(vm.count(
"scenario"))
450 if(vm.count(
"render-image"))
455 if(vm.count(
"generate-spritesheet"))
457 if(vm.count(
"screenshot"))
463 if(vm.count(
"script"))
465 if(vm.count(
"unsafe-scripts"))
467 if(vm.count(
"plugin"))
469 if(vm.count(
"server"))
470 server = vm[
"server"].as<std::string>();
471 if(vm.count(
"username"))
472 username = vm[
"username"].as<std::string>();
473 if(vm.count(
"password"))
474 password = vm[
"password"].as<std::string>();
475 if(vm.count(
"report"))
480 test = vm[
"test"].as<std::string>();
483 unit_test = vm[
"unit"].as<std::vector<std::string>>();
486 if(vm.count(
"showgui"))
488 if(vm.count(
"noreplaycheck"))
490 if(vm.count(
"turns"))
492 if(vm.count(
"strict-validation"))
494 if(vm.count(
"usercache-dir"))
496 if(vm.count(
"usercache-path"))
498 if(vm.count(
"userdata-dir"))
500 if(vm.count(
"userdata-path"))
502 if(vm.count(
"validcache"))
505 if(vm.count(
"validate"))
507 if(vm.count(
"validate-core"))
509 if(vm.count(
"validate-addon"))
511 if(vm.count(
"validate-schema"))
514 if(vm.count(
"use-schema"))
516 if(vm.count(
"version"))
518 if(vm.count(
"simple-version"))
523 if(vm.count(
"windowed"))
525 if(vm.count(
"with-replay"))
528 if(vm.count(
"wnoconsole"))
531 if(vm.count(
"no-log-sanitize"))
533 if(vm.count(
"log-to-file"))
535 if(vm.count(
"no-log-to-file"))
537 if(vm.count(
"all-translations"))
539 else if(vm.count(
"translations-over"))
540 translation_percent = std::clamp<unsigned int>(vm[
"translations-over"].as<unsigned int>(), 0, 100);
543 for (
const auto& option : parsed_options.options) {
544 if (!option.value.empty()) {
545 if (option.string_key ==
"log-error") {
547 }
else if (option.string_key ==
"log-warning") {
549 }
else if (option.string_key ==
"log-info") {
551 }
else if (option.string_key ==
"log-debug") {
553 }
else if (option.string_key ==
"log-none") {
580 PLAIN_LOG <<
"Unrecognized argument to --log-strict : " <<
severity <<
" . \nDisabling strict mode logging.";
586 const std::vector<std::string> tokens =
utils::split(resolution_string,
'x');
587 if(tokens.size() != 2) {
596 }
catch(
const std::invalid_argument &) {
605 std::vector<std::pair<unsigned int,std::string>> vec;
607 using namespace std::literals;
608 const std::string expected_format
609 =
"UINT"s + separator +
"STRING";
611 for(
const std::string &
s : strings) {
612 std::vector<std::string> tokens =
utils::split(
s, separator);
613 if(tokens.size() != 2) {
619 temp = lexical_cast<unsigned int>(tokens[0]);
624 vec.emplace_back(temp, std::move(tokens[1]));
631 std::vector<std::tuple<unsigned int,std::string,std::string>> vec;
633 using namespace std::literals;
634 const std::string expected_format
635 =
"UINT"s + separator +
"STRING" + separator +
"STRING";
637 for(
const std::string &
s : strings) {
638 const std::vector<std::string> tokens =
utils::split(
s, separator);
639 if(tokens.size() != 3) {
645 temp = lexical_cast<unsigned int>(tokens[0]);
650 vec.emplace_back(temp, tokens[1], tokens[2]);
657 os <<
"Usage: " << cmdline_opts.
args0_ <<
" [<options>] [<data-directory>]\n";
bad_commandline_resolution(const std::string &resolution)
bad_commandline_tuple(const std::string &str, const std::string &expected_format)
bool nogui
True if –nogui was given on the command line.
utils::optional< std::vector< std::pair< unsigned int, std::string > > > multiplayer_side
Non-empty if –side was given on the command line.
utils::optional< std::pair< int, int > > resolution
Pair of AxB values specified after –resolution.
utils::optional< std::string > validate_wml
Non-empty if –validate was given on the command line.
bool simple_version
True if –simple-version was given on the command line.
bool report
True if –report was given on the command line.
boost::program_options::options_description hidden_
bool headless_unit_test
True if –unit is used and –showgui is not present.
utils::optional< std::string > screenshot_map_file
Map file to make a screenshot of.
utils::optional< std::string > multiplayer_scenario
Non-empty if –scenario was given on the command line.
utils::optional< std::string > test
Non-empty if –test was given on the command line.
bool no_log_sanitize
True if –no-log-sanitize was given on the command line.
bool windowed
True if –windowed was given on the command line.
bool strict_lua
True if –strict-lua was given in the commandline.
utils::optional< std::string > language
Non-empty if –language was given on the command line.
std::vector< std::pair< unsigned int, std::string > > parse_to_uint_string_tuples_(const std::vector< std::string > &strings, char separator=':')
A helper function splitting vector of strings of format unsigned int:string to vector of tuples (unsi...
utils::optional< std::vector< std::string > > preprocess_defines
Defines that were given to the –preprocess option.
bool noreplaycheck
True if –noreplaycheck was given on the command line.
utils::optional< std::string > screenshot_output_file
Output file to put screenshot in.
void parse_log_domains_(const std::string &domains_string, const lg::severity severity)
utils::optional< std::string > usercache_dir
Non-empty if –usercache-dir was given on the command line.
utils::optional< int > max_fps
Max FPS specified by –max-fps option.
utils::optional< std::string > core_id
Non-empty if –core was given on the command line.
bool multiplayer_exit_at_end
True if –exit-at-and was given on the command line.
utils::optional< std::string > validate_addon
Non-empty if –validate-addon was given on the command line.
utils::optional< int > campaign_difficulty
Non-empty if –campaign-difficulty was given on the command line.
utils::optional< unsigned int > multiplayer_repeat
Repeats specified by –multiplayer-repeat option.
utils::optional< std::string > validate_schema
Non-empty if –validate-schema was given on the command line.
bool debug
True if –debug was given on the command line.
bool mptest
True if –mp-test was given on the command line.
void parse_log_strictness(const std::string &severity)
bool nosound
True if –nosound was given on the command line.
bool multiplayer
True if –multiplayer was given on the command line.
utils::optional< std::string > server
Non-empty if –server was given on the command line.
bool script_unsafe_mode
Whether to load the "package" package for the scripting environment.
utils::optional< std::string > userdata_dir
Non-empty if –userdata-dir was given on the command line.
std::vector< std::string > args_
utils::optional< unsigned int > translation_percent
Non-empty if –all-translations or –translations-over is given on the command line.
utils::optional< std::string > plugin_file
File to load a lua plugin (similar to a script) from.
bool nobanner
True if –nobanner was given on the command line.
utils::optional< std::vector< std::pair< lg::severity, std::string > > > log
Contains parsed arguments of –log-* (e.g.
bool validcache
True if –validcache was given on the command line.
utils::optional< std::string > generate_spritesheet
Path of which to generate a spritesheet.
std::vector< std::tuple< unsigned int, std::string, std::string > > parse_to_uint_string_string_tuples_(const std::vector< std::string > &strings, char separator=':')
A helper function splitting vector of strings of format unsigned int:string:string to vector of tuple...
bool nomusic
True if –nomusic was given on the command line.
bool clock
True if –clock was given on the command line.
utils::optional< std::string > render_image_dst
Output file to put rendered image path in.
utils::optional< std::string > render_image
Image path to render.
utils::optional< std::string > script_file
File to load lua script from.
boost::program_options::options_description visible_
utils::optional< std::string > campaign
Non-empty if –campaign was given on the command line.
utils::optional< std::string > logdomains
Non-empty if –logdomains was given on the command line.
bool new_widgets
True if –new-widgets was given on the command line.
utils::optional< std::string > preprocess_input_macros
Non-empty if –preprocess-input-macros was given on the command line.
bool preprocess
True if –preprocess was given on the command line.
utils::optional< unsigned int > rng_seed
RNG seed specified by –rng-seed option.
std::string diff_left
Files for diffing or patching.
utils::optional< std::vector< std::pair< unsigned int, std::string > > > multiplayer_ai_config
Non-empty if –ai-config was given on the command line.
bool data_path
True if –data-path was given on the command line.
bool version
True if –version was given on the command line.
utils::optional< std::string > multiplayer_label
Non-empty if –label was given on the command line.
bool allow_insecure
True if –allow-insecure was given in the commandline.
void parse_resolution_(const std::string &resolution_string)
utils::optional< std::string > multiplayer_era
Non-empty if –era was given on the command line.
utils::optional< std::string > validate_with
Non-empty if –use-schema was given on the command line.
bool noaddons
True if –noaddons was given on the command line.
bool fps
True if –fps was given on the command line.
utils::optional< std::string > output_file
Output filename for WML diff or preprocessing.
utils::optional< std::string > multiplayer_turns
Non-empty if –turns was given on the command line.
commandline_options(const std::vector< std::string > &args)
utils::optional< std::string > data_dir
Non-empty if –data-dir was given on the command line.
utils::optional< std::string > username
Non-empty if –username was given on the command line.
utils::optional< std::string > preprocess_target
Target (output) path that was given to the –preprocess option.
bool campaign_skip_story
True if –skip-story was given on the command line.
bool with_replay
True if –with-replay was given on the command line.
bool screenshot
True if –screenshot was given on the command line.
bool log_to_file
True if –log-to-file was given on the command line.
bool debug_lua
True if –debug-lua was given in the commandline.
std::vector< std::string > unit_test
Non-empty if –unit was given on the command line.
bool userdata_path
True if –userdata-path was given on the command line.
bool log_precise_timestamps
True if –log-precise was given on the command line.
utils::optional< std::string > preprocess_source_string
String to preprocess.
bool no_log_to_file
True if –no-log-to-file was given on the command line.
bool multiplayer_ignore_map_settings
True if –ignore-map-settings was given at the command line.
utils::optional< std::string > password
Non-empty if –password was given on the command line.
utils::optional< std::string > preprocess_output_macros
Non-empty if –preprocess-output-macros was given on the command line.
bool fullscreen
True if –fullscreen was given on the command line.
friend std::ostream & operator<<(std::ostream &os, const commandline_options &cmdline_opts)
To be used for printing help to the commandline.
bool any_validation_option() const
True if the –validate or any of the –validate-* options are given.
utils::optional< std::vector< std::pair< unsigned int, std::string > > > multiplayer_controller
Non-empty if –controller was given on the command line.
bool strict_validation
True if –strict-validation was given on the command line.
bool validate_core
True if –validate-core was given on the command line.
utils::optional< std::vector< std::pair< unsigned int, std::string > > > multiplayer_algorithm
Non-empty if –algorithm was given on the command line.
utils::optional< std::string > preprocess_path
Path to parse that was given to the –preprocess option.
bool usercache_path
True if –usercache-path was given on the command line.
bool nocache
True if –nocache was given on the command line.
utils::optional< std::vector< std::tuple< unsigned int, std::string, std::string > > > multiplayer_parm
Non-empty if –parm was given on the command line.
boost::program_options::options_description all_
utils::optional< std::string > campaign_scenario
Non-empty if –campaign-scenario was given on the command line.
utils::optional< std::string > load
Non-empty if –load was given on the command line.
A config object defines a single node in a WML file, with access to child nodes.
severity get_severity() const
static void validate(boost::any &v, const std::vector< std::string > &values, two_strings *, int)
Definitions for the interface to Wesnoth Markup Language (WML).
New lexcical_cast header.
Manage the empty-palette in the editor.
std::vector< game_tip > load(const config &cfg)
Loads the tips from a config.
bool new_widgets
Do we wish to use the new library or not.
static domain_map * domains
void set_strict_severity(severity severity)
int stoi(std::string_view str)
Same interface as std::stoi and meant as a drop in replacement, except:
std::vector< std::string > split(const config_attribute_value &val)
Thrown when a lexical_cast fails.
static map_location::direction s