Skip to content
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
39 changes: 39 additions & 0 deletions CommandLineParser.Tests/CustomerReportedTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
using System;
using System.Collections.Generic;
using System.Text;
using MatthiWare.CommandLine;
using Xunit;

namespace MatthiWare.CommandLineParser.Tests
{
public class CustomerReportedTests
{
/// <summary>
/// Running with *no* parameters at all crashes the command line parser #12
/// https://github.com/MatthiWare/CommandLineParser.Core/issues/12
/// </summary>
[Theory]
[InlineData(true, true)]
[InlineData(false, false)]
public void NoCommandLineArgumentsCrashesParser_Issue_12(bool required, bool outcome)
{
var parser = new CommandLineParser<OptionsModelIssue_12>();

parser.Configure(opt => opt.Test)
.Name("-1")
.Default(1)
.Required(required);

var parsed = parser.Parse(new[] { "app.exe" });

Assert.NotNull(parsed);

Assert.Equal(outcome, parsed.HasErrors);
}

private class OptionsModelIssue_12
{
public int Test { get; set; }
}
}
}
4 changes: 2 additions & 2 deletions CommandLineParser/CommandLineParser.csproj
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<RootNamespace>MatthiWare.CommandLine</RootNamespace>
<PackageId>MatthiWare.CommandLineParser</PackageId>
<Version>0.1.2</Version>
<Version>0.1.3</Version>
<Authors>Matthias Beerens</Authors>
<Company>MatthiWare</Company>
<Product>Command Line Parser</Product>
Expand Down
16 changes: 7 additions & 9 deletions CommandLineParser/CommandLineParser.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,21 @@
<package>
<metadata>
<id>MatthiWare.CommandLineParser</id>
<version>0.1.2</version>
<version>0.1.3</version>
<title>CommandLineParser.Core</title>
<authors>Matthias Beerens</authors>
<owners>Matthiee</owners>
<licenseUrl>https://github.com/MatthiWare/CommandLineParser.Core/blob/master/LICENSE</licenseUrl>
<projectUrl>https://github.com/MatthiWare/CommandLineParser.Core</projectUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>
Command Line Parser for .Net Core written in .Net Standard.

Configuration is done using an option class and/or fluent api.
This library allows to add commands with their own set of options as well.

For sample app and documentation visit: https://github.com/MatthiWare/CommandLineParser.Core
</description>
Command Line Parser for .Net Core written in .Net Standard.

Configuration is done through a option model class using attributes or fluent API can be used to configure the properties of the class.
This library allows to add commands with their own set of options as well.
</description>
<summary>A simple, light-weight and strongly typed command line parser. Configuration using fluent API and an options class. </summary>
<releaseNotes>Adds documentation.</releaseNotes>
<releaseNotes>Fixed issue where parser would crash when no arguments are supplied.</releaseNotes>
<copyright>Copyright Matthias Beerens 2018</copyright>
<tags>commandline parser commandline-parser</tags>
</metadata>
Expand Down
4 changes: 4 additions & 0 deletions CommandLineParser/Core/Parsing/ArgumentManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ private void Parse(IEnumerable<ICommandLineCommand> list)
{
int idx = FindIndex(item);

if (idx == -1) continue; // not found issue #12

SetArgumentUsed(idx, item);
}
}
Expand All @@ -61,6 +63,8 @@ private void ParseCommands(IEnumerable<CommandLineCommandBase> cmds)
{
int idx = FindIndex(cmd);

if (idx == -1) continue;

SetArgumentUsed(idx, cmd);

foreach (var option in cmd.Options)
Expand Down
2 changes: 1 addition & 1 deletion SampleApp/SampleApp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="MatthiWare.CommandLineParser" Version="0.1.1" />
<PackageReference Include="MatthiWare.CommandLineParser" Version="0.1.3" />
</ItemGroup>

</Project>