diff --git a/src/BizHawk.Client.EmuHawk/ArgParser.cs b/src/BizHawk.Client.Common/ArgParser.cs similarity index 73% rename from src/BizHawk.Client.EmuHawk/ArgParser.cs rename to src/BizHawk.Client.Common/ArgParser.cs index 900a2bb7de..99d4ac9a1a 100644 --- a/src/BizHawk.Client.EmuHawk/ArgParser.cs +++ b/src/BizHawk.Client.Common/ArgParser.cs @@ -5,7 +5,7 @@ using System.Collections.Generic; using System.Linq; using System.IO; -namespace BizHawk.Client.EmuHawk +namespace BizHawk.Client.Common { /// /// Parses command line flags from a string array into various instance fields. @@ -208,100 +208,10 @@ namespace BizHawk.Client.EmuHawk { return args.FirstOrDefault(arg => arg.StartsWith("--config=", StringComparison.InvariantCultureIgnoreCase))?.Substring(9); } - } - public sealed class ArgParserException : Exception - { - public ArgParserException(string message) : base(message) {} - } - - public readonly struct ParsedCLIFlags - { - public readonly string? cmdLoadSlot; - - public readonly string? cmdLoadState; - - public readonly string? cmdConfigPath; - - public readonly string? cmdConfigFile; - - public readonly string? cmdMovie; - - public readonly string? cmdDumpType; - - public readonly HashSet? _currAviWriterFrameList; - - public readonly int _autoDumpLength; - - public readonly bool printVersion; - - public readonly string? cmdDumpName; - - public readonly bool _autoCloseOnDump; - - public readonly bool _chromeless; - - public readonly bool startFullscreen; - - public readonly string? luaScript; - - public readonly bool luaConsole; - - public readonly (string IP, int Port)? SocketAddress; - - public readonly string? MMFFilename; - - public readonly (string? UrlGet, string? UrlPost)? HTTPAddresses; - - public readonly bool? audiosync; - - public readonly string? openExtToolDll; - - public readonly string? cmdRom; - - public ParsedCLIFlags(string? cmdLoadSlot, - string? cmdLoadState, - string? cmdConfigPath, - string? cmdConfigFile, - string? cmdMovie, - string? cmdDumpType, - HashSet? currAviWriterFrameList, - int autoDumpLength, - bool printVersion, - string? cmdDumpName, - bool autoCloseOnDump, - bool chromeless, - bool startFullscreen, - string? luaScript, - bool luaConsole, - (string IP, int Port)? socketAddress, - string? mmfFilename, - (string? UrlGet, string? UrlPost)? httpAddresses, - bool? audiosync, - string? openExtToolDll, - string? cmdRom) + public sealed class ArgParserException : Exception { - this.cmdLoadSlot = cmdLoadSlot; - this.cmdLoadState = cmdLoadState; - this.cmdConfigPath = cmdConfigPath; - this.cmdConfigFile = cmdConfigFile; - this.cmdMovie = cmdMovie; - this.cmdDumpType = cmdDumpType; - _currAviWriterFrameList = currAviWriterFrameList; - _autoDumpLength = autoDumpLength; - this.printVersion = printVersion; - this.cmdDumpName = cmdDumpName; - _autoCloseOnDump = autoCloseOnDump; - _chromeless = chromeless; - this.startFullscreen = startFullscreen; - this.luaScript = luaScript; - this.luaConsole = luaConsole; - SocketAddress = socketAddress; - MMFFilename = mmfFilename; - HTTPAddresses = httpAddresses; - this.audiosync = audiosync; - this.openExtToolDll = openExtToolDll; - this.cmdRom = cmdRom; + public ArgParserException(string message) : base(message) {} } } } diff --git a/src/BizHawk.Client.Common/ParsedCLIFlags.cs b/src/BizHawk.Client.Common/ParsedCLIFlags.cs new file mode 100644 index 0000000000..3e98e2b9af --- /dev/null +++ b/src/BizHawk.Client.Common/ParsedCLIFlags.cs @@ -0,0 +1,96 @@ +#nullable enable + +using System.Collections.Generic; + +namespace BizHawk.Client.Common +{ + public readonly struct ParsedCLIFlags + { + public readonly string? cmdLoadSlot; + + public readonly string? cmdLoadState; + + public readonly string? cmdConfigPath; + + public readonly string? cmdConfigFile; + + public readonly string? cmdMovie; + + public readonly string? cmdDumpType; + + public readonly HashSet? _currAviWriterFrameList; + + public readonly int _autoDumpLength; + + public readonly bool printVersion; + + public readonly string? cmdDumpName; + + public readonly bool _autoCloseOnDump; + + public readonly bool _chromeless; + + public readonly bool startFullscreen; + + public readonly string? luaScript; + + public readonly bool luaConsole; + + public readonly (string IP, int Port)? SocketAddress; + + public readonly string? MMFFilename; + + public readonly (string? UrlGet, string? UrlPost)? HTTPAddresses; + + public readonly bool? audiosync; + + public readonly string? openExtToolDll; + + public readonly string? cmdRom; + + public ParsedCLIFlags(string? cmdLoadSlot, + string? cmdLoadState, + string? cmdConfigPath, + string? cmdConfigFile, + string? cmdMovie, + string? cmdDumpType, + HashSet? currAviWriterFrameList, + int autoDumpLength, + bool printVersion, + string? cmdDumpName, + bool autoCloseOnDump, + bool chromeless, + bool startFullscreen, + string? luaScript, + bool luaConsole, + (string IP, int Port)? socketAddress, + string? mmfFilename, + (string? UrlGet, string? UrlPost)? httpAddresses, + bool? audiosync, + string? openExtToolDll, + string? cmdRom) + { + this.cmdLoadSlot = cmdLoadSlot; + this.cmdLoadState = cmdLoadState; + this.cmdConfigPath = cmdConfigPath; + this.cmdConfigFile = cmdConfigFile; + this.cmdMovie = cmdMovie; + this.cmdDumpType = cmdDumpType; + _currAviWriterFrameList = currAviWriterFrameList; + _autoDumpLength = autoDumpLength; + this.printVersion = printVersion; + this.cmdDumpName = cmdDumpName; + _autoCloseOnDump = autoCloseOnDump; + _chromeless = chromeless; + this.startFullscreen = startFullscreen; + this.luaScript = luaScript; + this.luaConsole = luaConsole; + SocketAddress = socketAddress; + MMFFilename = mmfFilename; + HTTPAddresses = httpAddresses; + this.audiosync = audiosync; + this.openExtToolDll = openExtToolDll; + this.cmdRom = cmdRom; + } + } +} diff --git a/src/BizHawk.Client.EmuHawk/MainForm.cs b/src/BizHawk.Client.EmuHawk/MainForm.cs index 30f6e341fb..3a26987b2e 100644 --- a/src/BizHawk.Client.EmuHawk/MainForm.cs +++ b/src/BizHawk.Client.EmuHawk/MainForm.cs @@ -320,7 +320,7 @@ namespace BizHawk.Client.EmuHawk { ArgParser.ParseArguments(out _argParser, args); } - catch (ArgParserException e) + catch (ArgParser.ArgParserException e) { MessageBox.Show(e.Message); }