diff options
| author | Anthony <Helios747@users.noreply.github.com> | 2017-02-26 15:51:35 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-02-26 15:51:35 -0800 |
| commit | 06428c3f14485e644006dcbb6329a4591b1d82ec (patch) | |
| tree | ac65d38d5209c50804b87bb5a44f2828eb8e37ca /Source/Core/UICommon/CommandLineParse.cpp | |
| parent | 722ff4c020b07ca0a285c70e26923cdab5623589 (diff) | |
| parent | c2d5fe3ec90dc46166ca31b7a7c608733c52ce34 (diff) | |
Merge pull request #4916 from leoetlino/cpp-optparse
Use cpp-optparse for command line parsing
Diffstat (limited to 'Source/Core/UICommon/CommandLineParse.cpp')
| -rw-r--r-- | Source/Core/UICommon/CommandLineParse.cpp | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/Source/Core/UICommon/CommandLineParse.cpp b/Source/Core/UICommon/CommandLineParse.cpp new file mode 100644 index 0000000000..e591a2accf --- /dev/null +++ b/Source/Core/UICommon/CommandLineParse.cpp @@ -0,0 +1,48 @@ +// Copyright 2017 Dolphin Emulator Project +// Licensed under GPLv2+ +// Refer to the license.txt file included. + +#include <OptionParser.h> + +#include "Common/Common.h" +#include "UICommon/CommandLineParse.h" + +namespace CommandLineParse +{ +std::unique_ptr<optparse::OptionParser> CreateParser(ParserOptions options) +{ + auto parser = std::make_unique<optparse::OptionParser>(); + parser->usage("usage: %prog [options]... [FILE]...").version(scm_rev_str); + + parser->add_option("--version").action("version").help("Print version and exit"); + + parser->add_option("-u", "--user").action("store").help("User folder path"); + parser->add_option("-m", "--movie").action("store").help("Play a movie file"); + parser->add_option("-e", "--exec") + .action("store") + .metavar("<file>") + .type("string") + .help("Load the specified file"); + + if (options == ParserOptions::IncludeGUIOptions) + { + parser->add_option("-d", "--debugger").action("store_true").help("Opens the debuger"); + parser->add_option("-l", "--logger").action("store_true").help("Opens the logger"); + parser->add_option("-b", "--batch").action("store_true").help("Exit Dolphin with emulation"); + parser->add_option("-c", "--confirm").action("store_true").help("Set Confirm on Stop"); + } + + // XXX: These two are setting configuration options + parser->add_option("-v", "--video_backend").action("store").help("Specify a video backend"); + parser->add_option("-a", "--audio_emulation") + .choices({"HLE", "LLE"}) + .help("Choose audio emulation from [%choices]"); + + return parser; +} + +optparse::Values& ParseArguments(optparse::OptionParser* parser, int argc, char** argv) +{ + return parser->parse_args(argc, argv); +} +} |
