diff --git a/Source/Core/DolphinWX/CMakeLists.txt b/Source/Core/DolphinWX/CMakeLists.txt index 8c104a877c..47bd895aa8 100644 --- a/Source/Core/DolphinWX/CMakeLists.txt +++ b/Source/Core/DolphinWX/CMakeLists.txt @@ -91,7 +91,7 @@ if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux") set(WXLIBS ${WXLIBS} dl) endif() -list(APPEND LIBS core uicommon) +list(APPEND LIBS core uicommon cpp-optparse) if(APPLE) if(wxWidgets_FOUND) diff --git a/Source/Core/UICommon/CMakeLists.txt b/Source/Core/UICommon/CMakeLists.txt index 1487b74baa..0f9a25e80a 100644 --- a/Source/Core/UICommon/CMakeLists.txt +++ b/Source/Core/UICommon/CMakeLists.txt @@ -1,8 +1,9 @@ -set(SRCS Disassembler.cpp +set(SRCS CommandLineParse.cpp + Disassembler.cpp UICommon.cpp USBUtils.cpp) -set(LIBS common) +set(LIBS common cpp-optparse) if(LIBUSB_FOUND) set(LIBS ${LIBS} ${LIBUSB_LIBRARIES}) endif() 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 + +#include "Common/Common.h" +#include "UICommon/CommandLineParse.h" + +namespace CommandLineParse +{ +std::unique_ptr CreateParser(ParserOptions options) +{ + auto parser = std::make_unique(); + 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("") + .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); +} +} diff --git a/Source/Core/UICommon/CommandLineParse.h b/Source/Core/UICommon/CommandLineParse.h new file mode 100644 index 0000000000..ffe2fc87ee --- /dev/null +++ b/Source/Core/UICommon/CommandLineParse.h @@ -0,0 +1,23 @@ +// Copyright 2017 Dolphin Emulator Project +// Licensed under GPLv2+ +// Refer to the license.txt file included. + +#include + +namespace optparse +{ +class OptionParser; +class Values; +} + +namespace CommandLineParse +{ +enum class ParserOptions +{ + IncludeGUIOptions, + OmitGUIOptions, +}; + +std::unique_ptr CreateParser(ParserOptions options); +optparse::Values& ParseArguments(optparse::OptionParser* parser, int argc, char** argv); +} diff --git a/Source/Core/UICommon/UICommon.vcxproj b/Source/Core/UICommon/UICommon.vcxproj index 6df52e697b..18d1ee0966 100644 --- a/Source/Core/UICommon/UICommon.vcxproj +++ b/Source/Core/UICommon/UICommon.vcxproj @@ -53,6 +53,7 @@ + @@ -60,6 +61,7 @@ +