From b07eca03408b5a8c365d58126bff18c9867c8bd2 Mon Sep 17 00:00:00 2001 From: BlackFrog1 Date: Wed, 22 Apr 2020 16:48:45 -0400 Subject: [PATCH 1/2] don't check for the slash (/) as a token on non-Windows OS; --- PowerArgs/OperatingSystem.cs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 PowerArgs/OperatingSystem.cs diff --git a/PowerArgs/OperatingSystem.cs b/PowerArgs/OperatingSystem.cs new file mode 100644 index 00000000..1285156f --- /dev/null +++ b/PowerArgs/OperatingSystem.cs @@ -0,0 +1,18 @@ +using System.Runtime.InteropServices; + +namespace PowerArgs +{ + /// + /// + /// https://mariusschulz.com/blog/detecting-the-operating-system-in-net-core + /// + public static class OperatingSystem + { + /// + /// Indicates if assembly is running on Windows OS + /// + /// True if running on Windows OS, false otherwise + public static bool IsWindows() => + RuntimeInformation.IsOSPlatform(OSPlatform.Windows); + } +} \ No newline at end of file From 2bd7079ce21d699f6cfaf8035e75b58eff35c16c Mon Sep 17 00:00:00 2001 From: BlackFrog1 Date: Wed, 22 Apr 2020 16:52:14 -0400 Subject: [PATCH 2/2] visual studio 2019 is show the code is not commit; --- PowerArgs/HelperTypesInternal/ArgParser.cs | 3 ++- PowerArgs/OperatingSystem.cs | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/PowerArgs/HelperTypesInternal/ArgParser.cs b/PowerArgs/HelperTypesInternal/ArgParser.cs index fff1c0d4..ba608636 100644 --- a/PowerArgs/HelperTypesInternal/ArgParser.cs +++ b/PowerArgs/HelperTypesInternal/ArgParser.cs @@ -33,7 +33,8 @@ internal static ParseResult Parse(CommandLineArgumentsDefinition Definition, str result.ImplicitParameters.Add(0, token); argumentPosition++; } - else if (token.StartsWith("/")) + // don't affect tokens on linux & macOS + else if (token.StartsWith("/") && OperatingSystem.IsWindows()) { var param = ParseSlashExplicitOption(token); if (result.ExplicitParameters.ContainsKey(param.Key)) throw new DuplicateArgException("Argument specified more than once: " + param.Key); diff --git a/PowerArgs/OperatingSystem.cs b/PowerArgs/OperatingSystem.cs index 1285156f..f07b24a5 100644 --- a/PowerArgs/OperatingSystem.cs +++ b/PowerArgs/OperatingSystem.cs @@ -3,7 +3,7 @@ namespace PowerArgs { /// - /// + /// helper class to detect which OS we are on /// https://mariusschulz.com/blog/detecting-the-operating-system-in-net-core /// public static class OperatingSystem