diff --git a/src/Magnum/MeshTools/sceneconverter.cpp b/src/Magnum/MeshTools/sceneconverter.cpp index 9a7b484d6..3e81983c3 100644 --- a/src/Magnum/MeshTools/sceneconverter.cpp +++ b/src/Magnum/MeshTools/sceneconverter.cpp @@ -94,7 +94,8 @@ and images present in the file. **This option is currently mandatory.** The `-i` / `--importer-options` and `-c` / `--converter-options` arguments accept a comma-separated list of key/value pairs to set in the importer / converter plugin configuration. If the `=` character is omitted, it's -equivalent to saying `key=true`. +equivalent to saying `key=true`; configuration subgroups are delimited with +`/`. @see @ref magnum-imageconverter */ @@ -147,7 +148,7 @@ images present in the file. The -i / --importer-options and -c / --converter-options arguments accept a comma-separated list of key/value pairs to set in the importer / converter plugin configuration. If the = character is omitted, it's equivalent to saying -key=true.)") +key=true; configuration subgroups are delimited with /.)") .parse(argc, argv); PluginManager::Manager importerManager{ diff --git a/src/Magnum/Trade/Implementation/converterUtilities.h b/src/Magnum/Trade/Implementation/converterUtilities.h index 4d617874a..387b0f148 100644 --- a/src/Magnum/Trade/Implementation/converterUtilities.h +++ b/src/Magnum/Trade/Implementation/converterUtilities.h @@ -46,20 +46,34 @@ void setOptions(PluginManager::AbstractPlugin& plugin, const std::string& option Utility::String::trimInPlace(keyValue[0]); Utility::String::trimInPlace(keyValue[2]); + std::vector keyParts = Utility::String::split(keyValue[0], '/'); + CORRADE_INTERNAL_ASSERT(!keyParts.empty()); + Utility::ConfigurationGroup* group = &plugin.configuration(); + bool groupNotRecognized = false; + for(std::size_t i = 0; i != keyParts.size() - 1; ++i) { + Utility::ConfigurationGroup* subgroup = group->group(keyParts[i]); + if(!subgroup) { + groupNotRecognized = true; + subgroup = group->addGroup(keyParts[i]); + } + group = subgroup; + } + /* Provide a warning message in case the plugin doesn't define given option in its default config. The plugin is not *required* to have those tho (could be backward compatibility entries, for example), so not an error. */ - if(!plugin.configuration().valueCount(keyValue[0])) + if(groupNotRecognized || !group->hasValue(keyParts.back())) { Warning{} << "Option" << keyValue[0] << "not recognized by" << plugin.plugin(); + } /* If the option doesn't have an =, treat it as a boolean flag that's set to true. While there's no similar way to do an inverse, it's still nicer than causing a fatal error with those. */ if(keyValue[1].empty()) - plugin.configuration().setValue(keyValue[0], true); + group->setValue(keyParts.back(), true); else - plugin.configuration().setValue(keyValue[0], keyValue[2]); + group->setValue(keyParts.back(), keyValue[2]); } } diff --git a/src/Magnum/Trade/imageconverter.cpp b/src/Magnum/Trade/imageconverter.cpp index df3ec9d1f..73b067332 100644 --- a/src/Magnum/Trade/imageconverter.cpp +++ b/src/Magnum/Trade/imageconverter.cpp @@ -99,7 +99,8 @@ need to be specified. The `-i` / `--importer-options` and `-c` / `--converter-options` arguments accept a comma-separated list of key/value pairs to set in the importer / converter plugin configuration. If the `=` character is omitted, it's -equivalent to saying `key=true`. +equivalent to saying `key=true`; configuration subgroups are delimited with +`/`. @section magnum-imageconverter-example Example usage @@ -168,7 +169,7 @@ be specified. The -i / --importer-options and -c / --converter-options arguments accept a comma-separated list of key/value pairs to set in the importer / converter plugin configuration. If the = character is omitted, it's equivalent to saying -key=true.)") +key=true; configuration subgroups are delimited with /.)") .parse(argc, argv); PluginManager::Manager importerManager{