Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Solved issues #66

Merged
merged 4 commits into from
Jun 2, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion GitHubReleaseNotes.txt
Original file line number Diff line number Diff line change
@@ -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
GitHubReleaseNotes.exe --output ReleaseNotes.md --skip-empty-releases --version 3.0.20
13 changes: 7 additions & 6 deletions ReleaseNotes.md
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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?
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace CommandLineParser.Arguments
/// with the value of <see cref="DefaultValue" />
/// when they do not appear on the command line.
/// </summary>
public interface IArgumentWithForceDefaultValue
public interface IArgumentWithForcedDefaultValue
{
///<summary>
/// Default value of the argument.
Expand Down
77 changes: 25 additions & 52 deletions src/CommandLineArgumentsParser/Arguments/ValueArgument.cs
Original file line number Diff line number Diff line change
@@ -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
{
Expand All @@ -23,7 +23,7 @@ namespace CommandLineParser.Arguments
/// Can be either builtin type or any user type (for which specific
/// conversion routine is provided - <see cref="ConvertValueHandler"/></typeparam>
/// <include file='..\Doc\CommandLineParser.xml' path='CommandLineParser/Arguments/ValueArgument/*'/>
public class ValueArgument<TValue> : Argument, IValueArgument, IArgumentWithDefaultValue, IArgumentWithForceDefaultValue
public class ValueArgument<TValue> : Argument, IValueArgument, IArgumentWithDefaultValue, IArgumentWithForcedDefaultValue
{
#region property backing fields

Expand Down Expand Up @@ -74,16 +74,7 @@ public ValueArgument(char shortName, string longName, string description)
/// String read from command line as arguments <see cref="Value"/>. Available after <see cref="Parse"/> is called.
/// </summary>
/// <exception cref="InvalidOperationException">String value was read before ParseCommandLine was called or when</exception>
public string StringValue
{
get
{
if (Parsed)
return _stringValue;
else
return null;
}
}
public string StringValue => Parsed ? _stringValue : null;

/// <summary>
/// Value of the ValueArgument, for arguments with single value.
Expand All @@ -110,11 +101,11 @@ public TValue Value
/// </summary>
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;

/// <summary>
/// When set to true, argument can appear on the command line with or without value, e.g. both is allowed:
Expand Down Expand Up @@ -147,8 +138,8 @@ public List<TValue> Values
/// <value></value>
object IValueArgument.Value
{
get { return Value; }
set { Value = (TValue)value; }
get => Value;
set => Value = (TValue)value;
}

IList<object> IValueArgument.Values
Expand Down Expand Up @@ -324,8 +315,8 @@ private ICollection<TValue> InitializeTargetCollection(MemberInfo info)
/// </summary>
public CultureInfo CultureInfo
{
get { return _cultureInfo; }
set { _cultureInfo = value; }
get => _cultureInfo;
set => _cultureInfo = value;
}

/// <summary>
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -466,12 +457,12 @@ public override void PrintValueInfo()
/// attribute and let the CommandLineParse take care of binding the attribute to the field.
/// </para>
/// </summary>
/// <remarks>Appliable to fields and properties (public).</remarks>
/// <remarks>Applicable to fields and properties (public).</remarks>
/// <remarks>Use <see cref="CommandLineParser.ExtractArgumentAttributes"/> for each object
/// you where you have delcared argument attributes.</remarks>
public class ValueArgumentAttribute : ArgumentAttribute
{
private static Type underlyingValueArgument;
private static Type _underlyingValueArgument;

/// <summary>
/// Creates proper generic <see cref="ValueArgument{TValue}"/> type for <paramref name="type"/>.
Expand All @@ -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;
}

/// <summary>
Expand Down Expand Up @@ -534,29 +525,17 @@ public ValueArgumentAttribute(Type type, char shortName, string longName)
/// </summary>
public object DefaultValue
{
get
{
return underlyingValueArgument.GetPropertyValue<object>("DefaultValue", Argument);
}
set
{
underlyingValueArgument.SetPropertyValue("DefaultValue", Argument, value);
}
get => _underlyingValueArgument.GetPropertyValue<object>("DefaultValue", Argument);
set => _underlyingValueArgument.SetPropertyValue("DefaultValue", Argument, value);
}

/// <summary>
/// Strong default value
/// Forced default value
/// </summary>
public object StrongDefaultValue
public object ForcedDefaultValue
{
get
{
return underlyingValueArgument.GetPropertyValue<object>("StrongDefaultValue", Argument);
}
set
{
underlyingValueArgument.SetPropertyValue("StrongDefaultValue", Argument, value);
}
get => _underlyingValueArgument.GetPropertyValue<object>("ForcedDefaultValue", Argument);
set => _underlyingValueArgument.SetPropertyValue("ForcedDefaultValue", Argument, value);
}

/// <summary>
Expand All @@ -569,14 +548,8 @@ public object StrongDefaultValue
/// </summary>
public bool ValueOptional
{
get
{
return underlyingValueArgument.GetPropertyValue<bool>("ValueOptional", Argument);
}
set
{
underlyingValueArgument.SetPropertyValue("ValueOptional", Argument, value);
}
get => _underlyingValueArgument.GetPropertyValue<bool>("ValueOptional", Argument);
set => _underlyingValueArgument.SetPropertyValue("ValueOptional", Argument, value);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<PackageReleaseNotes>See ReleaseNotes.md</PackageReleaseNotes>
<RepositoryType>git</RepositoryType>
<RepositoryUrl>https://github.com/j-maly/CommandLineParser</RepositoryUrl>
<Version>3.0.19</Version>
<Version>3.0.20</Version>
<DebugType>full</DebugType>
<!--<SignAssembly>True</SignAssembly>-->
<AssemblyOriginatorKeyFile>CommandLineArgumentsParser.pfx</AssemblyOriginatorKeyFile>
Expand Down
Loading