Change NoGUI over to using common command line parsing
This commit is contained in:
parent
f61363a791
commit
36a9479c17
|
@ -2,10 +2,10 @@
|
||||||
// Licensed under GPLv2+
|
// Licensed under GPLv2+
|
||||||
// Refer to the license.txt file included.
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
|
#include <OptionParser.h>
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <getopt.h>
|
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
|
@ -29,6 +29,7 @@
|
||||||
#include "Core/IOS/USB/Bluetooth/WiimoteDevice.h"
|
#include "Core/IOS/USB/Bluetooth/WiimoteDevice.h"
|
||||||
#include "Core/State.h"
|
#include "Core/State.h"
|
||||||
|
|
||||||
|
#include "UICommon/CommandLineParse.h"
|
||||||
#include "UICommon/UICommon.h"
|
#include "UICommon/UICommon.h"
|
||||||
|
|
||||||
#include "VideoCommon/RenderBase.h"
|
#include "VideoCommon/RenderBase.h"
|
||||||
|
@ -379,37 +380,24 @@ static Platform* GetPlatform()
|
||||||
|
|
||||||
int main(int argc, char* argv[])
|
int main(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
int ch, help = 0;
|
std::string boot_filename;
|
||||||
struct option longopts[] = {{"exec", no_argument, nullptr, 'e'},
|
auto parser = CommandLineParse::CreateParser(CommandLineParse::ParserOptions::OmitGUIOptions);
|
||||||
{"help", no_argument, nullptr, 'h'},
|
optparse::Values& options = CommandLineParse::ParseArguments(parser.get(), argc, argv);
|
||||||
{"version", no_argument, nullptr, 'v'},
|
std::vector<std::string> args = parser->args();
|
||||||
{nullptr, 0, nullptr, 0}};
|
|
||||||
|
|
||||||
while ((ch = getopt_long(argc, argv, "eh?v", longopts, 0)) != -1)
|
if (options.is_set("exec"))
|
||||||
{
|
{
|
||||||
switch (ch)
|
boot_filename = static_cast<const char*>(options.get("exec"));
|
||||||
{
|
|
||||||
case 'e':
|
|
||||||
break;
|
|
||||||
case 'h':
|
|
||||||
case '?':
|
|
||||||
help = 1;
|
|
||||||
break;
|
|
||||||
case 'v':
|
|
||||||
fprintf(stderr, "%s\n", scm_rev_str.c_str());
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
else if (args.size())
|
||||||
if (help == 1 || argc == optind)
|
|
||||||
{
|
{
|
||||||
fprintf(stderr, "%s\n\n", scm_rev_str.c_str());
|
boot_filename = args.front();
|
||||||
fprintf(stderr, "A multi-platform GameCube/Wii emulator\n\n");
|
args.erase(args.begin());
|
||||||
fprintf(stderr, "Usage: %s [-e <file>] [-h] [-v]\n", argv[0]);
|
}
|
||||||
fprintf(stderr, " -e, --exec Load the specified file\n");
|
else
|
||||||
fprintf(stderr, " -h, --help Show this help message\n");
|
{
|
||||||
fprintf(stderr, " -v, --version Print version and exit\n");
|
parser->print_help();
|
||||||
return 1;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
platform = GetPlatform();
|
platform = GetPlatform();
|
||||||
|
@ -435,9 +423,9 @@ int main(int argc, char* argv[])
|
||||||
|
|
||||||
DolphinAnalytics::Instance()->ReportDolphinStart("nogui");
|
DolphinAnalytics::Instance()->ReportDolphinStart("nogui");
|
||||||
|
|
||||||
if (!BootManager::BootCore(argv[optind]))
|
if (!BootManager::BootCore(boot_filename))
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Could not boot %s\n", argv[optind]);
|
fprintf(stderr, "Could not boot %s\n", boot_filename.c_str());
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue