Skip to content

Commit 525d474

Browse files
committed
Fixed a bug came out when solving issue #49.
1 parent 4f49653 commit 525d474

15 files changed

+55
-23
lines changed

CommandLine.sln

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

2-
Microsoft Visual Studio Solution File, Format Version 12.00
3-
# Visual Studio 2012
2+
Microsoft Visual Studio Solution File, Format Version 11.00
3+
# Visual Studio 2010
44
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CommandLine", "src\libcmdline\CommandLine.csproj", "{5DEA2811-2FFA-4959-830B-CAD3ACACABEB}"
55
EndProject
66
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CommandLine.Tests", "src\tests\CommandLine.Tests.csproj", "{86E1AC34-ED2D-4E42-8B95-65208FEA36C2}"

CommandLine.sln.DotSettings.user

+1-1
Large diffs are not rendered by default.

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Command Line Parser Library 1.9.4.209 beta for CLR.
1+
Command Line Parser Library 1.9.4.215 beta for CLR.
22
===
33
The Command Line Parser Library offers to CLR applications a clean and concise API for manipulating command line arguments and related tasks defining switches, options and verb commands. It allows you to display an help screen with an high degree of customization and a simple way to report syntax errors to the end user. Everything that is boring and repetitive to be programmed stands up on library shoulders, letting developers concentrate on core logic.
44
__The search for the command line parser for your application is over, with this library you got a solid parsing API constantly updated since 2005.__

Rakefile.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
PRODUCT = "Command Line Parser Library"
22
DESCRIPTION = "Command Line Parser Library allows CLR applications to define a syntax for parsing command line arguments."
3-
VERSION = "1.9.4.209"
3+
VERSION = "1.9.4.215"
44
INF_VERSION = VERSION + "-beta"
55
COPYRIGHT = "Copyright (c) 2005 - 2013 Giacomo Stelluti Scala"
66
LICENSE_URL = "https://raw.github.com/gsscoder/commandline/master/doc/LICENSE"
@@ -79,7 +79,7 @@ def invoke_runtime(cmd)
7979
a.version = a.file_version = VERSION
8080
a.copyright = COPYRIGHT
8181
a.custom_attributes :AssemblyInformationalVersion => INF_VERSION, :NeutralResourcesLanguage => "en-US"
82-
a.output_file = "src/CommonAssemblyInfo.cs"
82+
a.output_file = "src/SharedAssemblyInfo.cs"
8383
a.namespaces "System.Runtime.CompilerServices", "System.Resources"
8484
end
8585

doc/ChangeLog

+6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
2013-02-06 Giacomo Stelluti Scala <[email protected]>
2+
3+
* Solved an issue came out when solving https://github.com/gsscoder/commandline/issues/49
4+
(see VerbsFixture.cs#172).
5+
* Version incremented to 1.9.4.215 beta.
6+
17
2013-02-02 Giacomo Stelluti Scala <[email protected]>
28

39
* ParsingErrorsHandler delegate replaced by Action<HelpText>.

doc/README

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ Command Line Parser Library
33
Project Author/Coordinator: Giacomo Stelluti Scala
44
Main Contributor(s): Steven Evans, Kevin Moore, Dan Nemec (nemec), Alexander Fast (mizipzor)
55
--------------------------------------------------------------------------------------------
6-
Version 1.9.4.209 beta (*1)
7-
Latest Update: 02-02-2013
6+
Version 1.9.4.215 beta (*1)
7+
Latest Update: 2013-02-06
88

99
Git home:
1010
https://github.com/gsscoder/commandline

nuget/CommandLine.nuspec

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0"?>
22
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
33
<metadata>
4-
<version>1.9.4.209-beta</version>
4+
<version>1.9.4.215-beta</version>
55
<authors>Giacomo Stelluti Scala</authors>
66
<owners>Giacomo Stelluti Scala</owners>
77
<licenseUrl>https://github.com/gsscoder/commandline/blob/master/doc/LICENSE</licenseUrl>

src/CommonAssemblyInfo.cs renamed to src/SharedAssemblyInfo.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
using System.Runtime.InteropServices;
55
[assembly: AssemblyProduct("Command Line Parser Library")]
66
[assembly: AssemblyCopyright("Copyright (c) 2005 - 2013 Giacomo Stelluti Scala")]
7-
[assembly: AssemblyVersion("1.9.4.209")]
8-
[assembly: AssemblyFileVersion("1.9.4.209")]
7+
[assembly: AssemblyVersion("1.9.4.215")]
8+
[assembly: AssemblyFileVersion("1.9.4.215")]
99

10-
[assembly: AssemblyInformationalVersion("1.9.4.209-beta")]
10+
[assembly: AssemblyInformationalVersion("1.9.4.215-beta")]
1111
[assembly: NeutralResourcesLanguage("en-US")]

src/demo/CommandLine.Demo.csproj

+3-3
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,14 @@
3434
<Reference Include="System" />
3535
</ItemGroup>
3636
<ItemGroup>
37+
<Compile Include="..\SharedAssemblyInfo.cs">
38+
<Link>Properties\SharedAssemblyInfo.cs</Link>
39+
</Compile>
3740
<Compile Include="Program.cs" />
3841
<Compile Include="Properties\AssemblyInfo.cs" />
3942
<Compile Include="Program.Options.cs">
4043
<DependentUpon>Program.cs</DependentUpon>
4144
</Compile>
42-
<Compile Include="..\CommonAssemblyInfo.cs">
43-
<Link>Properties\CommonAssemblyInfo.cs</Link>
44-
</Compile>
4545
</ItemGroup>
4646
<ItemGroup>
4747
<ProjectReference Include="..\libcmdline\CommandLine.csproj">

src/libcmdline/CommandLine.csproj

+3-3
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@
7272
<Reference Include="System" />
7373
</ItemGroup>
7474
<ItemGroup>
75+
<Compile Include="..\SharedAssemblyInfo.cs">
76+
<Link>Properties\SharedAssemblyInfo.cs</Link>
77+
</Compile>
7578
<Compile Include="Attributes\BaseOptionAttribute.cs" />
7679
<Compile Include="Attributes\OptionAttribute.cs" />
7780
<Compile Include="Attributes\OptionArrayAttribute.cs" />
@@ -123,9 +126,6 @@
123126
<Compile Include="IParserState.cs" />
124127
<Compile Include="ParserState.cs" />
125128
<Compile Include="ParsingError.cs" />
126-
<Compile Include="..\CommonAssemblyInfo.cs">
127-
<Link>Properties\CommonAssemblyInfo.cs</Link>
128-
</Compile>
129129
<Compile Include="Extensions\TargetExtensions.cs" />
130130
</ItemGroup>
131131
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />

src/libcmdline/CommandLine.sln.DotSettings.user

+1-1
Large diffs are not rendered by default.

src/libcmdline/Parser.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ private bool DoParseArgumentsVerbs(ParserContext context)
319319
verbOption.CreateInstance(context.Target);
320320
}
321321
var verbResult = DoParseArgumentsCore(context.ToCoreInstance(verbOption));
322-
if (!verbResult)
322+
if (!verbResult && helpInfo != null)
323323
{
324324
// Particular verb parsing failed, we try to print its help
325325
DisplayHelpVerbText(context.Target, helpInfo, context.FirstArgument);

src/tests/CommandLine.Tests.csproj

+3-3
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@
4747
</Reference>
4848
</ItemGroup>
4949
<ItemGroup>
50+
<Compile Include="..\SharedAssemblyInfo.cs">
51+
<Link>Properties\SharedAssemblyInfo.cs</Link>
52+
</Compile>
5053
<Compile Include="Attributes\AttributesFixture.cs" />
5154
<Compile Include="Attributes\HelpOptionAttributeFixture.cs" />
5255
<Compile Include="Attributes\ValueListAttributeFixture.cs" />
@@ -101,9 +104,6 @@
101104
<Compile Include="Mocks\SimpleOptionsForAutoBuid.cs" />
102105
<Compile Include="Mocks\OptionsForPlugInScenario.cs" />
103106
<Compile Include="Mocks\OptionsWithUIntArray.cs" />
104-
<Compile Include="..\CommonAssemblyInfo.cs">
105-
<Link>Properties\CommonAssemblyInfo.cs</Link>
106-
</Compile>
107107
<Compile Include="Text\CopyrightInfoFixture.cs" />
108108
<Compile Include="Text\HeadingInfoFixture.cs" />
109109
<Compile Include="Text\HelpTextFixture.cs" />

src/tests/Mocks/OptionsWithVerbs.cs

+12
Original file line numberDiff line numberDiff line change
@@ -120,4 +120,16 @@ public OptionsWithVerbsNoHelp()
120120
[VerbOption("clone", HelpText = "Clone a repository into a new directory.")]
121121
public CloneSubOptions CloneVerb { get; set; }
122122
}
123+
124+
class WithRequiredSubOptions
125+
{
126+
[Option('m', "must", Required = true)]
127+
public string RequiredOption { get; set; }
128+
}
129+
130+
class OptionsWithVerbsNoHelp2 : OptionsWithVerbsNoHelp
131+
{
132+
[VerbOption("with")]
133+
public WithRequiredSubOptions WithRequired { get; set; }
134+
}
123135
}

src/tests/Parser/VerbsFixture.cs

+14
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,20 @@ public void Was_verb_option_invoked_returns_false_with_ordinary_options()
168168
parser.WasVerbOptionInvoked("--amend").Should().BeFalse();
169169
parser.WasVerbOptionInvoked("-a").Should().BeFalse();
170170
}
171+
172+
/// <summary>
173+
/// Issue came out when solving https://github.com/gsscoder/commandline/issues/49.
174+
/// </summary>
175+
[Fact]
176+
public void Should_fail_gracefully_when_no_getusage_is_defined()
177+
{
178+
var options = new OptionsWithVerbsNoHelp2();
179+
180+
var parser = new Parser();
181+
var result = parser.ParseArguments(new[] {"with", "--must"}, options);
182+
183+
result.Should().BeFalse();
184+
}
171185
}
172186
}
173187

0 commit comments

Comments
 (0)