Print invalid and unknown options on startup

This commit is contained in:
Robbert van der Helm
2020-10-13 14:20:51 +02:00
parent a125f7a535
commit a1162c2256
6 changed files with 87 additions and 15 deletions
+22 -9
View File
@@ -684,20 +684,33 @@ void PluginBridge::log_init_message() {
}
init_msg << "'" << std::endl;
bool other_options_set = false;
init_msg << "other options: '";
init_msg << "other options: ";
std::vector<std::string> other_options;
if (config.editor_double_embed) {
init_msg << "editor: double embed";
other_options_set = true;
other_options.push_back("editor: double embed");
}
if (config.hack_reaper_update_display) {
init_msg << "hack: REAPER 'audioMasterUpdateDisplay' workaround";
other_options_set = true;
other_options.push_back(
"hack: REAPER audioMasterUpdateDisplay() workaround");
}
if (!other_options_set) {
init_msg << "<none>";
if (!other_options.empty()) {
init_msg << join_quoted_strings(other_options) << std::endl;
} else {
init_msg << "'<none>'" << std::endl;
}
// To make debugging easier, we'll print both unrecognized options (that
// might be left over when an option gets removed) as well as options have
// the wrong argument types
if (!config.invalid_options.empty()) {
init_msg << "invalid arguments: "
<< join_quoted_strings(config.invalid_options)
<< " (check the readme for more information)" << std::endl;
}
if (!config.unknown_options.empty()) {
init_msg << "unrecognized options: "
<< join_quoted_strings(config.unknown_options) << std::endl;
}
init_msg << "'" << std::endl;
init_msg << std::endl;
// Include a list of enabled compile-tiem features, mostly to make debug
+11
View File
@@ -269,6 +269,17 @@ std::string get_wine_version() {
return version_string;
}
std::string join_quoted_strings(std::vector<std::string>& strings) {
bool is_first = true;
std::ostringstream joined_strigns{};
for (const auto& option : strings) {
joined_strigns << (is_first ? "'" : ", '") << option << "'";
is_first = false;
}
return joined_strigns.str();
}
Configuration load_config_for(const fs::path& yabridge_path) {
// First find the closest `yabridge.tmol` file for the plugin, falling back
// to default configuration settings if it doesn't exist
+8
View File
@@ -166,6 +166,14 @@ boost::filesystem::path get_this_file_location();
*/
std::string get_wine_version();
/**
* Join a vector of strings with commas while wrapping the strings in quotes.
* For example, `join_quoted_strings(std::vector<string>{"string", "another
* string", "also a string"})` outputs `"'string', 'another string', 'also a
* string'"`. This is used to format the initialisation message.
*/
std::string join_quoted_strings(std::vector<std::string>& strings);
/**
* Load the configuration that belongs to a copy of or symlink to
* `libyabridge.so`. If no configuration file could be found then this will