Split --config-{dir,path} into --user{config,data}-{dir,path}

This commit is contained in:
Alexander van Gessel 2013-12-28 12:38:11 +01:00
parent 65240630e8
commit bf8b05ff31
4 changed files with 42 additions and 14 deletions

View file

@ -121,6 +121,9 @@ Version 1.11.7+dev:
names such as "#foo.map".
* Fixed bug with modifications dependency check dialogs (bug #21365)
* Fixed bug with scrollbar overlaying mp description text (bug #21364)
* Split command line option --config-dir into --userconfig-dir and
--userdata-dir, with --userconfig-dir defaulting to --userdata-dir's
value on some platforms.
Version 1.11.7:
* Add-ons client:

View file

@ -48,8 +48,6 @@ commandline_options::commandline_options ( int argc, char** argv ) :
campaign_difficulty(),
campaign_scenario(),
clock(false),
config_path(false),
config_dir(),
data_dir(),
debug(false),
debug_lua(false),
@ -109,6 +107,10 @@ commandline_options::commandline_options ( int argc, char** argv ) :
screenshot_output_file(),
strict_validation(false),
test(),
userconfig_path(false),
userconfig_dir(),
userdata_path(false),
userdata_dir(),
validcache(false),
version(false),
windowed(false),
@ -126,8 +128,8 @@ commandline_options::commandline_options ( int argc, char** argv ) :
("bunzip2", po::value<std::string>(), "decompresses a file (<arg>.bz2) in bzip2 format and stores it without the .bz2 suffix. <arg>.bz2 will be removed.")
("bzip2", po::value<std::string>(), "compresses a file (<arg>) in bzip2 format, stores it as <arg>.bz2 and removes <arg>.")
("clock", "Adds the option to show a clock for testing the drawing timer.")
("config-dir", po::value<std::string>(), "sets the path of the user config 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.")
("config-path", "prints the path of the user config directory and exits.")
("config-dir", po::value<std::string>(), "sets the path of the userdata 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. DEPRECATED: use userdata-path and userconfig-path instead.")
("config-path", "prints the path of the userdata directory and exits. DEPRECATED: use userdata-path and userconfig-path instead.")
("data-dir", po::value<std::string>(), "overrides the data directory with the one specified.")
("debug,d", "enables additional command mode options in-game.")
("debug-lua", "enables some Lua debugging mechanisms")
@ -153,6 +155,10 @@ commandline_options::commandline_options ( int argc, char** argv ) :
("password", po::value<std::string>(), "uses <password> when connecting to a server, ignoring other preferences.")
("strict-validation", "makes validation errors fatal")
("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.")
("userconfig-dir", po::value<std::string>(), "sets the path of the user config 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/.config/wesnoth on X11 and to the userdata-dir on other systems.")
("userconfig-path", "prints the path of the user config directory and exits.")
("userdata-dir", po::value<std::string>(), "sets the path of the userdata 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.")
("userdata-path", "prints the path of the userdata directory and exits.")
("validcache", "assumes that the cache is valid. (dangerous)")
("version,v", "prints the game's version number and exits.")
("with-replay", "replays the file loaded with the --load option.")
@ -253,9 +259,9 @@ commandline_options::commandline_options ( int argc, char** argv ) :
if (vm.count("clock"))
clock = true;
if (vm.count("config-dir"))
config_dir = vm["config-dir"].as<std::string>();
userdata_dir = vm["config-dir"].as<std::string>(); //TODO: complain and remove
if (vm.count("config-path"))
config_path = true;
userdata_path = true; //TODO: complain and remove
if (vm.count("controller"))
multiplayer_controller = parse_to_uint_string_tuples_(vm["controller"].as<std::vector<std::string> >());
if (vm.count("data-dir"))
@ -376,6 +382,14 @@ commandline_options::commandline_options ( int argc, char** argv ) :
multiplayer_turns = vm["turns"].as<std::string>();
if (vm.count("strict-validation"))
strict_validation = true;
if (vm.count("userconfig-dir"))
userconfig_dir = vm["userconfig-dir"].as<std::string>();
if (vm.count("userconfig-path"))
userconfig_path = true;
if (vm.count("userdata-dir"))
userdata_dir = vm["userdata-dir"].as<std::string>();
if (vm.count("userdata-path"))
userdata_path = true;
if (vm.count("validcache"))
validcache = true;
if (vm.count("version"))

View file

@ -44,11 +44,7 @@ public:
boost::optional<std::string> campaign_scenario;
/// True if --clock was given on the command line. Enables
bool clock;
/// True if --config-path was given on the command line. Prints path to user config directory and exits.
bool config_path;
/// Non-empty if --config-dir was given on the command line. Sets the config dir to the specified one.
boost::optional<std::string> config_dir;
/// Non-empty if --config-dir was given on the command line. Sets the config dir to the specified one.
/// Non-empty if --data-dir was given on the command line. Sets the config dir to the specified one.
boost::optional<std::string> data_dir;
/// True if --debug was given on the command line. Enables debug mode.
bool debug;
@ -165,6 +161,14 @@ public:
bool strict_validation;
/// Non-empty if --test was given on the command line. Goes directly into test mode, into a scenario, if specified.
boost::optional<std::string> test;
/// True if --userconfig-path was given on the command line. Prints path to user config directory and exits.
bool userconfig_path;
/// Non-empty if --userconfig-dir was given on the command line. Sets the user config dir to the specified one.
boost::optional<std::string> userconfig_dir;
/// True if --userdata-path was given on the command line. Prints path to user data directory and exits.
bool userdata_path;
/// Non-empty if --userdata-dir was given on the command line. Sets the user data dir to the specified one.
boost::optional<std::string> userdata_dir;
/// True if --validcache was given on the command line. Makes Wesnoth assume the cache is valid.
bool validcache;
/// True if --version was given on the command line. Prints version and exits.

View file

@ -273,10 +273,17 @@ static int process_command_args(const commandline_options& cmdline_opts) {
// Options that don't change behavior based on any others should be checked alphabetically below.
if(cmdline_opts.config_dir) {
set_user_data_dir(*cmdline_opts.config_dir);
if(cmdline_opts.userconfig_dir) {
set_user_config_dir(*cmdline_opts.userconfig_dir);
}
if(cmdline_opts.config_path) {
if(cmdline_opts.userconfig_path) {
std::cout << get_user_config_dir() << '\n';
return 0;
}
if(cmdline_opts.userdata_dir) {
set_user_data_dir(*cmdline_opts.userdata_dir);
}
if(cmdline_opts.userdata_path) {
std::cout << get_user_data_dir() << '\n';
return 0;
}