summaryrefslogtreecommitdiff
path: root/Source/Core/UICommon/CommandLineParse.cpp
diff options
context:
space:
mode:
authorPierre Bourdon <delroth@gmail.com>2017-12-07 15:16:39 +0100
committerGitHub <noreply@github.com>2017-12-07 15:16:39 +0100
commit8a830074b64e0487afa523cd465de5ab40efb0a7 (patch)
tree2c51deeb7f21c84b4ffb6e2e0394fe0d103ac4ae /Source/Core/UICommon/CommandLineParse.cpp
parentecf30cfc749ff49697c8b6bf24efae4202a2bf61 (diff)
parent05c8d229afc3d88f4c368a648e96b049ccd2fba3 (diff)
Merge pull request #6220 from leoetlino/utf8
WX: Fix argument parsing
Diffstat (limited to 'Source/Core/UICommon/CommandLineParse.cpp')
-rw-r--r--Source/Core/UICommon/CommandLineParse.cpp31
1 files changed, 24 insertions, 7 deletions
diff --git a/Source/Core/UICommon/CommandLineParse.cpp b/Source/Core/UICommon/CommandLineParse.cpp
index 236cd86ba2..683738479f 100644
--- a/Source/Core/UICommon/CommandLineParse.cpp
+++ b/Source/Core/UICommon/CommandLineParse.cpp
@@ -3,6 +3,7 @@
// Refer to the license.txt file included.
#include <list>
+#include <optional>
#include <sstream>
#include <string>
#include <tuple>
@@ -40,8 +41,12 @@ public:
std::getline(buffer, section, '.');
std::getline(buffer, key, '=');
std::getline(buffer, value, '=');
- Config::System system = Config::GetSystemFromName(system_str);
- m_values.emplace_back(std::make_tuple(Config::ConfigLocation{system, section, key}, value));
+ const std::optional<Config::System> system = Config::GetSystemFromName(system_str);
+ if (system)
+ {
+ m_values.emplace_back(
+ std::make_tuple(Config::ConfigLocation{*system, section, key}, value));
+ }
}
}
@@ -105,17 +110,29 @@ std::unique_ptr<optparse::OptionParser> CreateParser(ParserOptions options)
return parser;
}
-optparse::Values& ParseArguments(optparse::OptionParser* parser, int argc, char** argv)
+static void AddConfigLayer(const optparse::Values& options)
{
- optparse::Values& options = parser->parse_args(argc, argv);
-
- const std::list<std::string>& config_args = options.all("config");
- if (config_args.size())
+ if (options.is_set_by_user("config"))
{
+ const std::list<std::string>& config_args = options.all("config");
Config::AddLayer(std::make_unique<CommandLineConfigLayerLoader>(
config_args, static_cast<const char*>(options.get("video_backend")),
static_cast<const char*>(options.get("audio_emulation"))));
}
+}
+
+optparse::Values& ParseArguments(optparse::OptionParser* parser, int argc, char** argv)
+{
+ optparse::Values& options = parser->parse_args(argc, argv);
+ AddConfigLayer(options);
+ return options;
+}
+
+optparse::Values& ParseArguments(optparse::OptionParser* parser,
+ const std::vector<std::string>& arguments)
+{
+ optparse::Values& options = parser->parse_args(arguments);
+ AddConfigLayer(options);
return options;
}
}