diff --git a/GitHubReleaseNotes.txt b/GitHubReleaseNotes.txt index fed7eaa..ea2c822 100644 --- a/GitHubReleaseNotes.txt +++ b/GitHubReleaseNotes.txt @@ -1,3 +1,3 @@ See https://github.com/StefH/GitHubReleaseNotes for more information. -GitHubReleaseNotes.exe --output ReleaseNotes.md --skip-empty-releases --version 3.0.19 \ No newline at end of file +GitHubReleaseNotes.exe --output ReleaseNotes.md --skip-empty-releases --version 3.0.20 \ No newline at end of file diff --git a/ReleaseNotes.md b/ReleaseNotes.md index 624ca66..14650cd 100644 --- a/ReleaseNotes.md +++ b/ReleaseNotes.md @@ -1,3 +1,10 @@ +# 3.0.20 (02 June 2019) +- [#57](https://github.com/j-maly/CommandLineParser/pull/57) - #55 Added StrongDefaultValue for ValueArgument contributed by [eapyl](https://github.com/eapyl) +- [#62](https://github.com/j-maly/CommandLineParser/issues/62) - getopt_long syntax +- [#63](https://github.com/j-maly/CommandLineParser/issues/63) - CheckMandatoryArguments not being evaluated +- [#64](https://github.com/j-maly/CommandLineParser/issues/64) - Message typo +- [#65](https://github.com/j-maly/CommandLineParser/issues/65) - Setup Code Shown On Documentation Page Missing Needed Parentheses [Documentation] + # 3.0.19 (21 November 2018) - [#61](https://github.com/j-maly/CommandLineParser/pull/61) - netstandard2.0 and added ReleaseNotes.md contributed by [StefH](https://github.com/StefH) - [#51](https://github.com/j-maly/CommandLineParser/issues/51) - Can't override Argument.Parse in my own argument class @@ -7,8 +14,6 @@ - [#58](https://github.com/j-maly/CommandLineParser/issues/58) - Error in the wiki - "Show Usage" section - [#60](https://github.com/j-maly/CommandLineParser/issues/60) - Support for Folder Argument -# 3.0.18 (13 October 2017) - # 3.0.15 (22 August 2017) - [#50](https://github.com/j-maly/CommandLineParser/pull/50) - Fix for Nullable contributed by [StefH](https://github.com/StefH) - [#48](https://github.com/j-maly/CommandLineParser/issues/48) - How is ArgumentRequiresOtherArgumentsCertification supposed to work? @@ -23,8 +28,6 @@ - [#45](https://github.com/j-maly/CommandLineParser/issues/45) - Using AcceptAdditionalArguments=false always throws exception - [#46](https://github.com/j-maly/CommandLineParser/issues/46) - Extend argument for supporting Guid values -# 3.0.11 (27 May 2017) - # 3.0.10 (27 May 2017) - [#43](https://github.com/j-maly/CommandLineParser/pull/43) - Parsing fails when there is equal sign (=) in argument contributed by [prog-rajkamal](https://github.com/prog-rajkamal) - [#27](https://github.com/j-maly/CommandLineParser/issues/27) - multiple items not parsed @@ -58,8 +61,6 @@ - [#34](https://github.com/j-maly/CommandLineParser/issues/34) - Missing docu 'multiple values with declarative syntax' - [#35](https://github.com/j-maly/CommandLineParser/issues/35) - Regex -# 3.0.0.2 (24 April 2016) - # 3.0.0.0 (21 February 2016) - [#1](https://github.com/j-maly/CommandLineParser/pull/1) - Added support for more frameworks contributed by [StefH](https://github.com/StefH) - [#2](https://github.com/j-maly/CommandLineParser/issues/2) - When ShowUsageOnEmptyCommandline is used, the parser does not indicate that nothing was parsed diff --git a/src/CommandLineArgumentsParser/Arguments/IArgumentWithForceDefaultValue.cs b/src/CommandLineArgumentsParser/Arguments/IArgumentWithForceDefaultValue.cs index b728ab2..72a320d 100644 --- a/src/CommandLineArgumentsParser/Arguments/IArgumentWithForceDefaultValue.cs +++ b/src/CommandLineArgumentsParser/Arguments/IArgumentWithForceDefaultValue.cs @@ -7,7 +7,7 @@ namespace CommandLineParser.Arguments /// with the value of /// when they do not appear on the command line. /// - public interface IArgumentWithForceDefaultValue + public interface IArgumentWithForcedDefaultValue { /// /// Default value of the argument. diff --git a/src/CommandLineArgumentsParser/Arguments/ValueArgument.cs b/src/CommandLineArgumentsParser/Arguments/ValueArgument.cs index 050bcb4..5b4d9b5 100644 --- a/src/CommandLineArgumentsParser/Arguments/ValueArgument.cs +++ b/src/CommandLineArgumentsParser/Arguments/ValueArgument.cs @@ -1,10 +1,10 @@ +using CommandLineParser.Compatibility; +using CommandLineParser.Exceptions; using System; -using System.Linq; using System.Collections.Generic; using System.Globalization; +using System.Linq; using System.Reflection; -using CommandLineParser.Compatibility; -using CommandLineParser.Exceptions; namespace CommandLineParser.Arguments { @@ -23,7 +23,7 @@ namespace CommandLineParser.Arguments /// Can be either builtin type or any user type (for which specific /// conversion routine is provided - /// - public class ValueArgument : Argument, IValueArgument, IArgumentWithDefaultValue, IArgumentWithForceDefaultValue + public class ValueArgument : Argument, IValueArgument, IArgumentWithDefaultValue, IArgumentWithForcedDefaultValue { #region property backing fields @@ -74,16 +74,7 @@ public ValueArgument(char shortName, string longName, string description) /// String read from command line as arguments . Available after is called. /// /// String value was read before ParseCommandLine was called or when - public string StringValue - { - get - { - if (Parsed) - return _stringValue; - else - return null; - } - } + public string StringValue => Parsed ? _stringValue : null; /// /// Value of the ValueArgument, for arguments with single value. @@ -110,11 +101,11 @@ public TValue Value /// public TValue DefaultValue { get; set; } - public TValue StrongDefaultValue { get; set; } + public TValue ForcedDefaultValue { get; set; } - object IArgumentWithDefaultValue.DefaultValue { get { return DefaultValue; } } + object IArgumentWithDefaultValue.DefaultValue => DefaultValue; - object IArgumentWithForceDefaultValue.DefaultValue { get { return StrongDefaultValue; } } + object IArgumentWithForcedDefaultValue.DefaultValue => ForcedDefaultValue; /// /// When set to true, argument can appear on the command line with or without value, e.g. both is allowed: @@ -147,8 +138,8 @@ public List Values /// object IValueArgument.Value { - get { return Value; } - set { Value = (TValue)value; } + get => Value; + set => Value = (TValue)value; } IList IValueArgument.Values @@ -324,8 +315,8 @@ private ICollection InitializeTargetCollection(MemberInfo info) /// public CultureInfo CultureInfo { - get { return _cultureInfo; } - set { _cultureInfo = value; } + get => _cultureInfo; + set => _cultureInfo = value; } /// @@ -434,7 +425,7 @@ protected virtual TValue DefaultConvert(string stringValue) public override void Init() { base.Init(); - _value = StrongDefaultValue; + _value = ForcedDefaultValue; _values.Clear(); _stringValue = string.Empty; } @@ -466,12 +457,12 @@ public override void PrintValueInfo() /// attribute and let the CommandLineParse take care of binding the attribute to the field. /// /// - /// Appliable to fields and properties (public). + /// Applicable to fields and properties (public). /// Use for each object /// you where you have delcared argument attributes. public class ValueArgumentAttribute : ArgumentAttribute { - private static Type underlyingValueArgument; + private static Type _underlyingValueArgument; /// /// Creates proper generic type for . @@ -482,8 +473,8 @@ private static Type CreateProperValueArgumentType(Type type) { Type genericType = typeof(ValueArgument<>); Type constructedType = genericType.MakeGenericType(type); - underlyingValueArgument = constructedType; - return underlyingValueArgument; + _underlyingValueArgument = constructedType; + return _underlyingValueArgument; } /// @@ -534,29 +525,17 @@ public ValueArgumentAttribute(Type type, char shortName, string longName) /// public object DefaultValue { - get - { - return underlyingValueArgument.GetPropertyValue("DefaultValue", Argument); - } - set - { - underlyingValueArgument.SetPropertyValue("DefaultValue", Argument, value); - } + get => _underlyingValueArgument.GetPropertyValue("DefaultValue", Argument); + set => _underlyingValueArgument.SetPropertyValue("DefaultValue", Argument, value); } /// - /// Strong default value + /// Forced default value /// - public object StrongDefaultValue + public object ForcedDefaultValue { - get - { - return underlyingValueArgument.GetPropertyValue("StrongDefaultValue", Argument); - } - set - { - underlyingValueArgument.SetPropertyValue("StrongDefaultValue", Argument, value); - } + get => _underlyingValueArgument.GetPropertyValue("ForcedDefaultValue", Argument); + set => _underlyingValueArgument.SetPropertyValue("ForcedDefaultValue", Argument, value); } /// @@ -569,14 +548,8 @@ public object StrongDefaultValue /// public bool ValueOptional { - get - { - return underlyingValueArgument.GetPropertyValue("ValueOptional", Argument); - } - set - { - underlyingValueArgument.SetPropertyValue("ValueOptional", Argument, value); - } + get => _underlyingValueArgument.GetPropertyValue("ValueOptional", Argument); + set => _underlyingValueArgument.SetPropertyValue("ValueOptional", Argument, value); } } } \ No newline at end of file diff --git a/src/CommandLineArgumentsParser/CommandLineArgumentsParser.csproj b/src/CommandLineArgumentsParser/CommandLineArgumentsParser.csproj index 60949db..2dca79f 100644 --- a/src/CommandLineArgumentsParser/CommandLineArgumentsParser.csproj +++ b/src/CommandLineArgumentsParser/CommandLineArgumentsParser.csproj @@ -16,7 +16,7 @@ See ReleaseNotes.md git https://github.com/j-maly/CommandLineParser - 3.0.19 + 3.0.20 full CommandLineArgumentsParser.pfx diff --git a/src/CommandLineArgumentsParser/CommandLineParser.cs b/src/CommandLineArgumentsParser/CommandLineParser.cs index 11bf7fb..f187351 100644 --- a/src/CommandLineArgumentsParser/CommandLineParser.cs +++ b/src/CommandLineArgumentsParser/CommandLineParser.cs @@ -1,13 +1,13 @@ +using CommandLineParser.Arguments; +using CommandLineParser.Compatibility; +using CommandLineParser.Exceptions; +using CommandLineParser.Validation; using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Reflection; using System.Text.RegularExpressions; -using CommandLineParser.Arguments; -using CommandLineParser.Compatibility; -using CommandLineParser.Exceptions; -using CommandLineParser.Validation; namespace CommandLineParser { @@ -297,14 +297,22 @@ public void ParseCommandLine(string[] args) } } - PerformMandatoryArgumentsCheck(); - PerformCertificationCheck(); - ParsingSucceeded = true; + if (CheckMandatoryArguments) + { + PerformMandatoryArgumentsCheck(); + } + + if (CheckArgumentCertifications) + { + PerformCertificationCheck(); + } + + ParsingSucceeded = true; } /// /// Searches for fields with - /// ArgumentAttributes or some of its descendats. Adds new argument + /// ArgumentAttributes or some of its descendants. Adds new argument /// for each such a field and defines binding of the argument to the field. /// Also adds object to collection /// for each of . @@ -364,10 +372,8 @@ private Argument ParseArgument(string curArg) argName = curArg.Substring(2); if (argName.Length == 1) { - throw new CommandLineFormatException(String.Format( - Messages.EXC_FORMAT_SHORTNAME_PREFIX, argName)); + throw new CommandLineFormatException(string.Format(Messages.EXC_FORMAT_SHORTNAME_PREFIX, argName)); } - } else { @@ -375,25 +381,26 @@ private Argument ParseArgument(string curArg) argName = curArg.Substring(1); if (argName.Length != 1) { - throw new CommandLineFormatException( - String.Format(Messages.EXC_FORMAT_LONGNAME_PREFIX, argName)); + throw new CommandLineFormatException(string.Format(Messages.EXC_FORMAT_LONGNAME_PREFIX, argName)); } } Argument argument = LookupArgument(argName); - if (argument != null) return argument; - else - throw new UnknownArgumentException(string.Format(Messages.EXC_ARG_UNKNOWN, argName), argName); - } - else - { - throw new CommandLineFormatException(Messages.EXC_FORMAT_SINGLEHYPHEN); + if (argument != null) + { + return argument; + } + + throw new UnknownArgumentException(string.Format(Messages.EXC_ARG_UNKNOWN, argName), argName); } + + throw new CommandLineFormatException(Messages.EXC_FORMAT_SINGLEHYPHEN); } - else - return null; + + return null; } - else if (curArg[0] == '/') + + if (curArg[0] == '/') { if (AcceptSlash) { @@ -405,37 +412,39 @@ private Argument ParseArgument(string curArg) } string argName = curArg.Substring(1); Argument argument = LookupArgument(argName); - if (argument != null) return argument; - else throw new UnknownArgumentException(string.Format(Messages.EXC_ARG_UNKNOWN, argName), argName); - } - else - { - throw new CommandLineFormatException(Messages.EXC_FORMAT_DOUBLESLASH); + if (argument != null) + { + return argument; + } + + throw new UnknownArgumentException(string.Format(Messages.EXC_ARG_UNKNOWN, argName), argName); } + + throw new CommandLineFormatException(Messages.EXC_FORMAT_DOUBLESLASH); } - else - return null; - } - else - /* - * curArg does not start with '-' character and therefore it is considered additional argument. - * Argument parsing ends here. - */ + return null; + } + + /* + * curArg does not start with '-' character and therefore it is considered additional argument. + * Argument parsing ends here. + */ + return null; } /// - /// Checks whether or non-optional arguments were defined on the command line. + /// Checks whether non-optional arguments were defined on the command line. /// /// Non-optional argument not defined. /// , private void PerformMandatoryArgumentsCheck() { _arguments.ForEach(delegate (Argument arg) - { - if (!arg.Optional && !arg.Parsed) - throw new MandatoryArgumentNotSetException(string.Format(Messages.EXC_MISSING_MANDATORY_ARGUMENT, arg.Name), arg.Name); - }); + { + if (!arg.Optional && !arg.Parsed) + throw new MandatoryArgumentNotSetException(string.Format(Messages.EXC_MISSING_MANDATORY_ARGUMENT, arg.Name), arg.Name); + }); } /// @@ -467,7 +476,7 @@ private void ParseAdditionalArguments(List argsList, int i) } AdditionalArgumentsSettings.ProcessArguments(); } - else if(i < argsList.Count) + else if (i < argsList.Count) { // only throw when there are any additional arguments throw new CommandLineFormatException( @@ -521,7 +530,7 @@ private void ExpandShortSwitches(IList argsList) } } } - } + } private void ExpandValueArgumentsWithEqualSigns(IList argsList) { @@ -530,7 +539,7 @@ private void ExpandValueArgumentsWithEqualSigns(IList argsList) for (int i = 0; i < argsList.Count; i++) { string arg = argsList[i]; - + Regex r = new Regex("([^=]*)=(.*)"); if (AcceptEqualSignSyntaxForValueArguments && r.IsMatch(arg)) { @@ -562,7 +571,7 @@ private void ExpandValueArgumentsWithEqualSigns(IList argsList) { argsList.Insert(i, singleValue); i++; - } + } } i--; } @@ -571,7 +580,7 @@ private void ExpandValueArgumentsWithEqualSigns(IList argsList) argsList.Insert(i, argNameWithSep); i++; argsList.Insert(i, argValue); - } + } } } } @@ -633,7 +642,7 @@ public void PrintUsage(TextWriter outputStream) outputStream.Write("-" + c); comma = true; } - if (!String.IsNullOrEmpty(argument.LongName)) + if (!string.IsNullOrEmpty(argument.LongName)) { if (comma) outputStream.Write(", "); @@ -652,12 +661,12 @@ public void PrintUsage(TextWriter outputStream) outputStream.Write(Messages.MSG_OPTIONAL); outputStream.WriteLine("... {0} ", argument.Description); - if (!String.IsNullOrEmpty(argument.Example)) + if (!string.IsNullOrEmpty(argument.Example)) { outputStream.WriteLine(Messages.MSG_EXAMPLE_FORMAT, argument.Example); } - if (!String.IsNullOrEmpty(argument.FullDescription)) + if (!string.IsNullOrEmpty(argument.FullDescription)) { outputStream.WriteLine(); outputStream.WriteLine(argument.FullDescription); diff --git a/src/CommandLineArgumentsParser/Messages.cs b/src/CommandLineArgumentsParser/Messages.cs index 74fbdd1..519d760 100644 --- a/src/CommandLineArgumentsParser/Messages.cs +++ b/src/CommandLineArgumentsParser/Messages.cs @@ -50,7 +50,7 @@ internal static class Messages public static string EXC_FORMAT_LONGNAME_PREFIX = "Only short argument names(single character) are allowed after single '-' character(e.g. -v). For long names use double '-' format(e.g. '--ver'). Wrong argument is: {0}"; - public static string EXC_FORMAT_SHORTNAME_PREFIX = "If short name argument is used, it must be prefixed with single '-' character.Wrong argument is: {0}"; + public static string EXC_FORMAT_SHORTNAME_PREFIX = "If short name argument is used, it must be prefixed with single '-' character. Wrong argument is: {0}"; public static string EXC_FORMAT_SINGLEHYPHEN = "Found character '-' not followed by an argument."; diff --git a/src/Tests/MandatoryArgumentsTests.cs b/src/Tests/MandatoryArgumentsTests.cs new file mode 100644 index 0000000..3a90b47 --- /dev/null +++ b/src/Tests/MandatoryArgumentsTests.cs @@ -0,0 +1,109 @@ +using CommandLineParser.Arguments; +using CommandLineParser.Exceptions; +using FluentAssertions; +using System; +using Xunit; + +namespace Tests +{ + public class MandatoryArgumentsTests + { + class TestTargetWithOptionalTrue + { + [ValueArgument(typeof(string), 's', Optional = true)] + public string Severity { get; set; } + } + + class TestTargetWithOptionalFalse + { + [ValueArgument(typeof(string), 's', Optional = false)] + public string Severity { get; set; } + } + + [Fact] + public void ParseCommandLine_WithCheckMandatoryArgumentsTrue_OptionalArgumentTrue_and_SuppliedArgument_Works() + { + // Assign + string[] args = { "-s", "test" }; + + var commandLineParser = new CommandLineParser.CommandLineParser(); + var target = new TestTargetWithOptionalTrue(); + commandLineParser.ExtractArgumentAttributes(target); + + // Act + commandLineParser.ParseCommandLine(args); + + // Assert + target.Severity.Should().Be("test"); + } + + [Fact] + public void ParseCommandLine_WithCheckMandatoryArgumentsTrue_OptionalArgumentFalse_and_SuppliedArgument_Works() + { + // Assign + string[] args = { "-s", "test" }; + + var commandLineParser = new CommandLineParser.CommandLineParser(); + var target = new TestTargetWithOptionalFalse(); + commandLineParser.ExtractArgumentAttributes(target); + + // Act + commandLineParser.ParseCommandLine(args); + + // Assert + target.Severity.Should().Be("test"); + } + + [Fact] + public void ParseCommandLine_WithCheckMandatoryArgumentsTrue_OptionalArgumentTrue_and_MissingArgument_Works() + { + // Assign + string[] args = { }; + + var commandLineParser = new CommandLineParser.CommandLineParser(); + var target = new TestTargetWithOptionalTrue(); + commandLineParser.ExtractArgumentAttributes(target); + + // Act + commandLineParser.ParseCommandLine(args); + + // Assert + target.Severity.Should().BeNull(); + } + + [Fact] + public void ParseCommandLine_WithCheckMandatoryArgumentsTrue_OptionalArgumentTrue_and_MissingArgument_ThrowsException() + { + // Assign + string[] args = { }; + + var commandLineParser = new CommandLineParser.CommandLineParser(); + var target = new TestTargetWithOptionalFalse(); + commandLineParser.ExtractArgumentAttributes(target); + + // Act + Action act = () => commandLineParser.ParseCommandLine(args); + + // Assert + act.Should().Throw(); + } + + [Fact] + public void ParseCommandLine_WithCheckMandatoryArgumentsFalse_OptionalArgumentTrue_and_MissingArgument_Works() + { + // Assign + string[] args = { }; + + var commandLineParser = new CommandLineParser.CommandLineParser { CheckMandatoryArguments = false }; + + var target = new TestTargetWithOptionalFalse(); + commandLineParser.ExtractArgumentAttributes(target); + + // Act + commandLineParser.ParseCommandLine(args); + + // Assert + target.Severity.Should().BeNull(); + } + } +} \ No newline at end of file diff --git a/src/Tests/Tests.AdditionalArguments.cs b/src/Tests/Tests.AdditionalArguments.cs index e825d7e..a4bc0ed 100644 --- a/src/Tests/Tests.AdditionalArguments.cs +++ b/src/Tests/Tests.AdditionalArguments.cs @@ -24,7 +24,7 @@ public CommandLineParser.CommandLineParser InitAdditionalArguments() BoundedValueArgument optimization = new BoundedValueArgument('o', "optimization", 0, 3); - EnumeratedValueArgument color = new EnumeratedValueArgument('c', "color", new[] {"red", "green", "blue"}); + EnumeratedValueArgument color = new EnumeratedValueArgument('c', "color", new[] { "red", "green", "blue" }); FileArgument inputFile = new FileArgument('i', "input", "Input file"); inputFile.FileMustExist = false; @@ -34,11 +34,11 @@ public CommandLineParser.CommandLineParser InitAdditionalArguments() DirectoryArgument inputDirectory = new DirectoryArgument('d', "directory", "Input directory"); inputDirectory.DirectoryMustExist = false; - point.ConvertValueHandler = delegate(string stringValue) + point.ConvertValueHandler = delegate (string stringValue) { if (stringValue.StartsWith("[") && stringValue.EndsWith("]")) { - string[] parts =stringValue.Substring(1, stringValue.Length - 2).Split(';', ','); + string[] parts = stringValue.Substring(1, stringValue.Length - 2).Split(';', ','); Point p = new Point(); p.x = int.Parse(parts[0]); p.y = int.Parse(parts[1]); @@ -78,7 +78,7 @@ public CommandLineParser.CommandLineParser InitAdditionalArguments() return commandLineParser; } - [Fact] + [Fact] public void AdditionalArguments_MissingAdditionalArgumentsException() { string[] args = new[] { "-d", "C:\\Input", "file1.txt" }; diff --git a/src/Tests/Tests.DeclarativeValue.cs b/src/Tests/Tests.DeclarativeValue.cs index 34134ad..38e29b0 100644 --- a/src/Tests/Tests.DeclarativeValue.cs +++ b/src/Tests/Tests.DeclarativeValue.cs @@ -25,7 +25,7 @@ public class DeclarativeValueTestOptionsTrue { private bool defaultTrue; - [ValueArgument(typeof(bool), 't', StrongDefaultValue = true)] + [ValueArgument(typeof(bool), 't', ForcedDefaultValue = true)] public bool DefaultTrue { get { return defaultTrue; } diff --git a/src/Tests/Tests.Parser.cs b/src/Tests/Tests.Parser.cs index 25d6e3f..a37cdf6 100644 --- a/src/Tests/Tests.Parser.cs +++ b/src/Tests/Tests.Parser.cs @@ -1,9 +1,6 @@ -using System.IO; using CommandLineParser.Arguments; -using CommandLineParser.Exceptions; -using ParserTest; -using Xunit; using System; +using Xunit; namespace Tests { @@ -17,7 +14,7 @@ public void ParserResult_ShouldBeFalse_WhenOnlyHelpWasShown() string[] args = new string[0]; commandLineParser.ParseCommandLine(args); - + Assert.Equal(false, commandLineParser.ParsingSucceeded); } @@ -40,7 +37,7 @@ public void Parser_shouldAllowArgsWithTheSameToUpperConversion_whenIgnoreCaseIsN var parser = new CommandLineParser.CommandLineParser(); parser.Arguments.Add(new SwitchArgument('a', "switch", false)); parser.Arguments.Add(new SwitchArgument('b', "SWiTCH", false)); - parser.IgnoreCase = false; + parser.IgnoreCase = false; // ACT parser.ParseCommandLine(new string[0]); diff --git a/src/Tests/Tests.ValueArgument.cs b/src/Tests/Tests.ValueArgument.cs index f172bf9..972d617 100644 --- a/src/Tests/Tests.ValueArgument.cs +++ b/src/Tests/Tests.ValueArgument.cs @@ -1,6 +1,5 @@ using CommandLineParser.Arguments; using CommandLineParser.Exceptions; -using System; using System.Collections.Generic; using Xunit; @@ -14,7 +13,7 @@ class ValueArgumentParsingTarget [ValueArgument(typeof(int), 'i', AllowMultiple = true)] public List Numbers; - [ValueArgument(typeof(int), 'v', DefaultValue = 2, StrongDefaultValue = 1, ValueOptional = true)] + [ValueArgument(typeof(int), 'v', DefaultValue = 2, ForcedDefaultValue = 1, ValueOptional = true)] public int Version; [ValueArgument(typeof(int?), 'n', Optional = true)] diff --git a/src/Tests/Tests.csproj b/src/Tests/Tests.csproj index 4dc754f..496f11e 100644 --- a/src/Tests/Tests.csproj +++ b/src/Tests/Tests.csproj @@ -14,6 +14,7 @@ +