diff --git a/src/BizHawk.Client.Common/ArgParser.cs b/src/BizHawk.Client.Common/ArgParser.cs index a3345b21c3..72d4bf7634 100644 --- a/src/BizHawk.Client.Common/ArgParser.cs +++ b/src/BizHawk.Client.Common/ArgParser.cs @@ -7,6 +7,7 @@ using System.CommandLine.Parsing; using System.Linq; using System.Net.Sockets; +using BizHawk.Common; using BizHawk.Common.CollectionExtensions; using BizHawk.Common.StringExtensions; @@ -147,13 +148,13 @@ namespace BizHawk.Client.Common public static int? ParseArguments(out ParsedCLIFlags parsed, string[] args) { parsed = default; - if (args.Length is not 0) Console.WriteLine($"parsing command-line flags: {string.Join(" ", args)}"); + if (args.Length is not 0) Console.Error.WriteLine($"parsing command-line flags: {string.Join(" ", args)}"); var result = Parser.Parse(args); if (result.Errors.Count is not 0) { // write all to stdout and show first in modal dialog (done in `catch` block in `Program`) - Console.WriteLine("failed to parse command-line arguments:"); - foreach (var error in result.Errors) Console.WriteLine(error.Message); + Console.Error.WriteLine("failed to parse command-line arguments:"); + foreach (var error in result.Errors) Console.Error.WriteLine(error.Message); throw new ArgParserException($"failed to parse command-line arguments: {result.Errors[0].Message}"); } var triggeredGeneratedOption = GeneratedOptions.FirstOrDefault(o => result.FindResultFor(o) is not null); @@ -168,6 +169,12 @@ namespace BizHawk.Client.Common return exitCode; } } + if (result.GetValueForOption(OptionQueryAppVersion)) + { + // means e.g. `./EmuHawkMono.sh --version` was passed, so print that and exit immediately + Console.WriteLine(VersionInfo.GetEmuVersion()); + return 0; + } var autoDumpLength = result.GetValueForOption(OptionAVDumpEndAtFrame); HashSet? currAviWriterFrameList = null; @@ -218,7 +225,6 @@ namespace BizHawk.Client.Common cmdDumpType: result.GetValueForOption(OptionAVDumpType), currAviWriterFrameList: currAviWriterFrameList, autoDumpLength: autoDumpLength ?? 0, - printVersion: result.GetValueForOption(OptionQueryAppVersion), cmdDumpName: result.GetValueForOption(OptionAVDumpName), autoCloseOnDump: result.GetValueForOption(OptionAVDumpQuitWhenDone), chromeless: result.GetValueForOption(OptionLaunchChromeless), diff --git a/src/BizHawk.Client.Common/ParsedCLIFlags.cs b/src/BizHawk.Client.Common/ParsedCLIFlags.cs index bf98c55771..81dd4aa8b9 100644 --- a/src/BizHawk.Client.Common/ParsedCLIFlags.cs +++ b/src/BizHawk.Client.Common/ParsedCLIFlags.cs @@ -21,8 +21,6 @@ namespace BizHawk.Client.Common public readonly int _autoDumpLength; - public readonly bool printVersion; - public readonly string? cmdDumpName; public readonly bool _autoCloseOnDump; @@ -61,7 +59,6 @@ namespace BizHawk.Client.Common string? cmdDumpType, HashSet? currAviWriterFrameList, int autoDumpLength, - bool printVersion, string? cmdDumpName, bool autoCloseOnDump, bool chromeless, @@ -85,7 +82,6 @@ namespace BizHawk.Client.Common this.cmdDumpType = cmdDumpType; _currAviWriterFrameList = currAviWriterFrameList; _autoDumpLength = autoDumpLength; - this.printVersion = printVersion; this.cmdDumpName = cmdDumpName; _autoCloseOnDump = autoCloseOnDump; _chromeless = chromeless; diff --git a/src/BizHawk.Client.EmuHawk/MainForm.cs b/src/BizHawk.Client.EmuHawk/MainForm.cs index 3f023ffc81..998f524eb2 100644 --- a/src/BizHawk.Client.EmuHawk/MainForm.cs +++ b/src/BizHawk.Client.EmuHawk/MainForm.cs @@ -896,15 +896,6 @@ namespace BizHawk.Client.EmuHawk ToggleFullscreen(); } - // Simply exit the program if the version is asked for - if (_argParser.printVersion) - { - // Print the version - Console.WriteLine(VersionInfo.GetEmuVersion()); - // Return and leave - return _exitCode; - } - CaptureMouse(Config.CaptureMouse); // incantation required to get the program reliably on top of the console window