mirror of
https://github.com/spice2x/spice2x.github.io.git
synced 2026-08-01 22:30:42 -07:00
launcher: option to make command line args take precedence (#327)
## Link to GitHub Issue, if one exists Fixes #190 ## Description of change When `-cmdoverride` is specified, any command line arguments are taken first before merging with what is in the config file. ## Testing Still testing...
This commit is contained in:
@@ -244,6 +244,11 @@ int main_implementation(int argc, char *argv[]) {
|
||||
// parse arguments
|
||||
LAUNCHER_OPTIONS = launcher::parse_options(argc, argv);
|
||||
|
||||
// command line override (must be done before merging options with cfg)
|
||||
if (LAUNCHER_OPTIONS->at(launcher::Options::OptionConflictResolution).value_bool()) {
|
||||
launcher::USE_CMD_OVERRIDE = true;
|
||||
}
|
||||
|
||||
// determine config file path - must be done before anything else
|
||||
const auto &cfg_path = LAUNCHER_OPTIONS->at(launcher::Options::ConfigurationPath);
|
||||
if (cfg_path.is_active()) {
|
||||
@@ -285,6 +290,7 @@ int main_implementation(int argc, char *argv[]) {
|
||||
cfg::CONFIGURATOR_TYPE = cfg::ConfigType::Config;
|
||||
cfg_run = true;
|
||||
}
|
||||
|
||||
if (options[launcher::Options::EAmusementEmulation].value_bool() &&
|
||||
options[launcher::Options::ServiceURL].is_active() &&
|
||||
!cfg::CONFIGURATOR_STANDALONE) {
|
||||
@@ -1220,6 +1226,38 @@ int main_implementation(int argc, char *argv[]) {
|
||||
}
|
||||
log_info("launcher", "arguments:\n{}", arguments.str());
|
||||
|
||||
// print out conflicts
|
||||
size_t conflicts = 0;
|
||||
for (const auto &option : options) {
|
||||
if (option.conflicting && option.get_definition().type != OptionType::Bool) {
|
||||
conflicts += 1;
|
||||
if (launcher::USE_CMD_OVERRIDE) {
|
||||
log_warning(
|
||||
"launcher",
|
||||
"multiple values for -{}, command line args take precedence: {}",
|
||||
option.get_definition().name,
|
||||
option.value);
|
||||
} else {
|
||||
log_warning(
|
||||
"launcher",
|
||||
"multiple values for -{}, spicecfg values take precedence: {}",
|
||||
option.get_definition().name,
|
||||
option.value);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (conflicts) {
|
||||
if (launcher::USE_CMD_OVERRIDE) {
|
||||
log_info(
|
||||
"launcher",
|
||||
"user specified -cmdoverride, therefore command line args took precedence over spicecfg");
|
||||
} else {
|
||||
log_warning(
|
||||
"launcher",
|
||||
"spicecfg values take precedence over command line args; to change this behavior, use -cmdoverride");
|
||||
}
|
||||
}
|
||||
|
||||
if (options[launcher::Options::FullscreenResolution].is_active()) {
|
||||
std::pair<uint32_t, uint32_t> result;
|
||||
if (parse_width_height(options[launcher::Options::FullscreenResolution].value_text(), result)) {
|
||||
|
||||
Reference in New Issue
Block a user