Improve user-friendliness of the validation options
* Fixes #4223, by making the --validate and --validate-* options imply --nocache. * Fixes #4224, showing an error if you misspell the id argument to --validate-addon. The application doesn't (but should) quit automatically to avoid the user spending time on a non-functional validation run, however it does at least disable all add-ons, which should have the same end result. * Shows a warning that --validate-addon needs the user to play the add-on, it doesn't automatically check the add-on. This was my misunderstanding when logging issue #4225, which has now been repurposed into a feature request for a new tool that does what I thought --validate-addon did.
This commit is contained in:
parent
028a470e07
commit
3f93c263a9
3 changed files with 26 additions and 2 deletions
|
@ -287,7 +287,7 @@ commandline_options::commandline_options (const std::vector<std::string>& args)
|
|||
parsing_opts.add_options()
|
||||
("use-schema,S", po::value<std::string>(), "specify a schema to validate WML against (defaults to the core schema)")
|
||||
("validate,V", po::value<std::string>(), "validate a specified WML file against a schema")
|
||||
("validate-addon", po::value<std::string>(), "validate the specified addon's WML against the schema")
|
||||
("validate-addon", po::value<std::string>(), "validate the specified addon's WML against the schema. Requires the user to play the campaign (in the GUI) to trigger the validation.")
|
||||
("validate-core", "validate the core WML against the schema")
|
||||
("validate-schema", po::value<std::string>(), "validate a specified WML schema")
|
||||
("diff,D", po::value<two_strings>()->multitoken(), "diff two preprocessed WML documents")
|
||||
|
@ -516,6 +516,7 @@ commandline_options::commandline_options (const std::vector<std::string>& args)
|
|||
userdata_path = true;
|
||||
if (vm.count("validcache"))
|
||||
validcache = true;
|
||||
// If you add a new validate-* option, remember the any_validation_option() function
|
||||
if (vm.count("validate"))
|
||||
validate_wml = vm["validate"].as<std::string>();
|
||||
if (vm.count("validate-core"))
|
||||
|
@ -524,6 +525,7 @@ commandline_options::commandline_options (const std::vector<std::string>& args)
|
|||
validate_addon = vm["validate-addon"].as<std::string>();
|
||||
if (vm.count("validate-schema"))
|
||||
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>();;
|
||||
if (vm.count("version"))
|
||||
|
@ -650,3 +652,8 @@ config commandline_options::to_config() const {
|
|||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool commandline_options::any_validation_option() const
|
||||
{
|
||||
return validate_addon || validate_core || validate_schema || validate_with || validate_wml;
|
||||
}
|
||||
|
|
|
@ -46,6 +46,9 @@ public:
|
|||
|
||||
config to_config() const; /* Used by lua scrips. Not all of the options need to be exposed here, just those exposed to lua */
|
||||
|
||||
/// True if the --validate or any of the --validate-* options are given.
|
||||
bool any_validation_option() const;
|
||||
|
||||
/// Non-empty if --bunzip2 was given on the command line. Uncompresses a .bz2 file and exits.
|
||||
boost::optional<std::string> bunzip2;
|
||||
/// Non-empty if --bzip2 was given on the command line. Compresses a file to .bz2 and exits.
|
||||
|
|
|
@ -62,7 +62,9 @@ game_config_manager::game_config_manager(
|
|||
assert(!singleton);
|
||||
singleton = this;
|
||||
|
||||
if(cmdline_opts_.nocache) {
|
||||
// All of the validation options imply --nocache, as the validation happens during cache
|
||||
// rebuilding. If the cache isn't rebuilt, validation is silently skipped.
|
||||
if(cmdline_opts_.nocache || cmdline_opts_.any_validation_option()) {
|
||||
cache_.set_use_cache(false);
|
||||
}
|
||||
if(cmdline_opts_.validcache) {
|
||||
|
@ -565,6 +567,18 @@ void game_config_manager::load_addons_cfg()
|
|||
}
|
||||
}
|
||||
|
||||
if(cmdline_opts_.validate_addon) {
|
||||
if(!addon_cfgs_.count(*cmdline_opts_.validate_addon)) {
|
||||
ERR_CONFIG << "Didn’t find an add-on for --validate-addon - check whether the id has a typo" << std::endl;
|
||||
const std::string log_msg = formatter()
|
||||
<< "Didn't find an add-on for --validate-addon - check whether the id has a typo";
|
||||
error_log.push_back(log_msg);
|
||||
throw game::error("Did not find an add-on for --validate-addon");
|
||||
}
|
||||
|
||||
WRN_CONFIG << "Note: for --validate-addon to find errors, you have to play (in the GUI) a game that uses the add-on.";
|
||||
}
|
||||
|
||||
if(!error_addons.empty()) {
|
||||
const std::size_t n = error_addons.size();
|
||||
const std::string& msg1 =
|
||||
|
|
Loading…
Add table
Reference in a new issue