diff --git a/AMWD.Common.AspNetCore/AMWD.Common.AspNetCore.csproj b/AMWD.Common.AspNetCore/AMWD.Common.AspNetCore.csproj index 19c391f..34fa151 100644 --- a/AMWD.Common.AspNetCore/AMWD.Common.AspNetCore.csproj +++ b/AMWD.Common.AspNetCore/AMWD.Common.AspNetCore.csproj @@ -2,7 +2,7 @@ Debug;Release;DebugLocal - net6.0;net7.0 + net6.0 10.0 AMWD.Common.AspNetCore diff --git a/AMWD.Common.EntityFrameworkCore/AMWD.Common.EntityFrameworkCore.csproj b/AMWD.Common.EntityFrameworkCore/AMWD.Common.EntityFrameworkCore.csproj index d6697c1..abe3b58 100644 --- a/AMWD.Common.EntityFrameworkCore/AMWD.Common.EntityFrameworkCore.csproj +++ b/AMWD.Common.EntityFrameworkCore/AMWD.Common.EntityFrameworkCore.csproj @@ -2,7 +2,7 @@ Debug;Release;DebugLocal - net6.0;net7.0 + net6.0 10.0 AMWD.Common.EntityFrameworkCore @@ -28,18 +28,11 @@ - + - - - - - - - diff --git a/AMWD.Common/Cli/Argument.cs b/AMWD.Common/Cli/Argument.cs new file mode 100644 index 0000000..79a0b9b --- /dev/null +++ b/AMWD.Common/Cli/Argument.cs @@ -0,0 +1,36 @@ +namespace AMWD.Common.Cli +{ + /// + /// Represents a logical argument in the command line. Options with their additional + /// parameters are combined in one argument. + /// + [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + public class Argument + { + /// + /// Initialises a new instance of the class. + /// + /// The that is set in this argument; or null. + /// The additional parameter values for the option; or the argument value. + internal Argument(Option option, string[] values) + { + Option = option; + Values = values; + } + + /// + /// Gets the that is set in this argument; or null. + /// + public Option Option { get; private set; } + + /// + /// Gets the additional parameter values for the option; or the argument value. + /// + public string[] Values { get; private set; } + + /// + /// Gets the first item of ; or null. + /// + public string Value => Values.Length > 0 ? Values[0] : null; + } +} diff --git a/AMWD.Common/Cli/CommandLineParser.cs b/AMWD.Common/Cli/CommandLineParser.cs new file mode 100644 index 0000000..2936d2a --- /dev/null +++ b/AMWD.Common/Cli/CommandLineParser.cs @@ -0,0 +1,366 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace AMWD.Common.Cli +{ + /// + /// Provides options and arguments parsing from command line arguments or a single string. + /// + public class CommandLineParser + { + #region Private data + + private string[] args; + private List parsedArguments; + private readonly List