From d515b1bdadf8f8a9343ac50ab2d3ce6741cdd7fc Mon Sep 17 00:00:00 2001 From: YoshiRulz Date: Thu, 4 Jul 2024 22:53:26 +1000 Subject: [PATCH] Document bare minimum of CLI flag parsing behaviour --- src/BizHawk.Client.Common/ArgParser.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/BizHawk.Client.Common/ArgParser.cs b/src/BizHawk.Client.Common/ArgParser.cs index 94a0efa768..73297b5e3b 100644 --- a/src/BizHawk.Client.Common/ArgParser.cs +++ b/src/BizHawk.Client.Common/ArgParser.cs @@ -78,10 +78,12 @@ namespace BizHawk.Client.Common } else if (argDowncased.StartsWithOrdinal("--dump-type=")) { + // ignored unless `--dump-name` also passed cmdDumpType = argDowncased.Substring(argDowncased.IndexOf('=') + 1); } else if (argDowncased.StartsWithOrdinal("--dump-frames=")) { + // comma-separated list of integers, indices of frames which should be included in the A/V dump (encoding) string list = argDowncased.Substring(argDowncased.IndexOf('=') + 1); currAviWriterFrameList = new(); currAviWriterFrameList.AddRange(list.Split(',').Select(int.Parse)); @@ -94,6 +96,7 @@ namespace BizHawk.Client.Common } else if (argDowncased.StartsWithOrdinal("--dump-name=")) { + // ignored unless `--dump-type` also passed cmdDumpName = arg.Substring(arg.IndexOf('=') + 1); } else if (argDowncased.StartsWithOrdinal("--dump-length=")) @@ -117,6 +120,7 @@ namespace BizHawk.Client.Common else if (argDowncased.StartsWithOrdinal("--lua=")) { luaScript = arg.Substring(arg.IndexOf('=') + 1); + // implies `--luaconsole` luaConsole = true; } else if (argDowncased.StartsWithOrdinal("--luaconsole")) @@ -125,15 +129,18 @@ namespace BizHawk.Client.Common } else if (argDowncased.StartsWithOrdinal("--socket_port=")) { + // must be paired with `--socket_ip` var port = ushort.TryParse(arg.Substring(14), out var i1) ? i1 : (ushort) 0; if (port > 0) socketPort = port; } else if (argDowncased.StartsWithOrdinal("--socket_ip=")) { + // must be paired with `--socket_port` socketIP = argDowncased.Substring(argDowncased.IndexOf('=') + 1); } else if (argDowncased.StartsWithOrdinal("--socket_udp")) { + // ignored unless `--socket_ip --socket_port` also passed socketProtocol = ProtocolType.Udp; } else if (argDowncased.StartsWithOrdinal("--mmf=")) @@ -150,6 +157,8 @@ namespace BizHawk.Client.Common } else if (argDowncased.StartsWithOrdinal("--audiosync=")) { + // `true` is the only truthy value, all else falsey + // if not set, uses remembered state from config audiosync = argDowncased.Substring(argDowncased.IndexOf('=') + 1) == "true"; } else if (argDowncased.StartsWithOrdinal("--open-ext-tool-dll=")) @@ -161,6 +170,10 @@ namespace BizHawk.Client.Common } else if (argDowncased.StartsWithOrdinal("--userdata=")) { + // pairs in the format `k1:v1;k2:v2` (mind your shell escape sequences) + // if the value is `true`/`false` it's interpreted as a boolean, + // if it's a valid 32-bit signed integer e.g. `-1234` it's interpreted as such, if it's a valid 32-bit float e.g. `12.34` it's interpreted as such, + // else it's interpreted as a string userdataUnparsedPairs = new(); foreach (var s in arg.Substring(11).Split(';')) {