Skip to content

Commit c41bb22

Browse files
committed
Verify Remaining Arguments
1 parent 57592bc commit c41bb22

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

ManyConsole.CommandLineUtils/ConsoleCommand.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,15 @@ internal void Register(CommandLineApplication app)
6464
return 2;
6565
}
6666

67+
if(RemainingArgumentsCount != 0){
68+
var actCount =(remainingArgs?.Values.Count() ?? 0);
69+
if(actCount < RemainingArgumentsCount){
70+
c.Out.WriteLine("Invalid number of arguments-- expected {1} more.", RemainingArgumentsCount - actCount);
71+
c.ShowHelp();
72+
return 2;
73+
}
74+
}
75+
6776
return Run(remainingArgs?.Values.ToArray() ?? new string []{});
6877
});
6978
});

ManyConsole.CommandLineUtils/ManyConsole.CommandLineUtils.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,16 @@
55
<Description>A near drop-in replacement for ManyConsole, wrapping Microsoft.Extensions.CommandLineUtils</Description>
66
<Authors> Jay Tuley, Frank Schwieterman, Jonathan Pryor </Authors>
77
<Copyright>Copyright 2017</Copyright>
8-
<AssemblyVersion>1.0.2.0</AssemblyVersion>
9-
<FileVersion>1.0.2.0</FileVersion>
8+
<AssemblyVersion>1.0.3.0</AssemblyVersion>
9+
<FileVersion>1.0.3.0</FileVersion>
1010
<PackageProjectUrl>https://github.com/jbtule/ManyConsole.CommandLineUtils</PackageProjectUrl>
1111
<PackageLicenseUrl>https://github.com/jbtule/ManyConsole.CommandLineUtils/blob/master/LICENSE.txt</PackageLicenseUrl>
1212
<PackageTags>command-line console parsing manyconsole ndesk CommandLineUtils</PackageTags>
1313
<IncludeSymbols>True</IncludeSymbols>
1414
<IncludeSource>True</IncludeSource>
1515
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
1616
<PackageRequireLicenseAcceptance>True</PackageRequireLicenseAcceptance>
17-
<Version>1.0.2-alpha</Version>
17+
<Version>1.0.3-alpha</Version>
1818
</PropertyGroup>
1919

2020
<ItemGroup Condition="'$(TargetFramework)'=='net20'">

0 commit comments

Comments
 (0)