mirror of
https://github.com/nsnail/spectre.console.git
synced 2025-04-16 00:42:51 +08:00
parent
3f561e0902
commit
55633b59fa
@ -67,8 +67,12 @@ namespace Spectre.Console.Cli
|
||||
throw CommandConfigurationException.BranchHasNoChildren(command);
|
||||
}
|
||||
|
||||
// Multiple vector arguments?
|
||||
var arguments = command.Parameters.OfType<CommandArgument>();
|
||||
var arguments = command.Parameters
|
||||
.OfType<CommandArgument>()
|
||||
.OrderBy(x => x.Position)
|
||||
.ToList();
|
||||
|
||||
// vector arguments?
|
||||
if (arguments.Any(x => x.ParameterKind == ParameterKind.Vector))
|
||||
{
|
||||
// Multiple vector arguments for command?
|
||||
@ -77,7 +81,7 @@ namespace Spectre.Console.Cli
|
||||
throw CommandConfigurationException.TooManyVectorArguments(command);
|
||||
}
|
||||
|
||||
// Make sure that vector arguments are specified last.
|
||||
// Make sure that the vector argument is specified last.
|
||||
if (arguments.Last().ParameterKind != ParameterKind.Vector)
|
||||
{
|
||||
throw CommandConfigurationException.VectorArgumentNotSpecifiedLast(command);
|
||||
@ -85,7 +89,6 @@ namespace Spectre.Console.Cli
|
||||
}
|
||||
|
||||
// Arguments
|
||||
var argumnets = command.Parameters.OfType<CommandArgument>();
|
||||
foreach (var argument in arguments)
|
||||
{
|
||||
if (argument.Required && argument.DefaultValue != null)
|
||||
|
@ -13,10 +13,10 @@ namespace Spectre.Console.Tests.Data
|
||||
|
||||
public class MultipleArgumentVectorSpecifiedFirstSettings : CommandSettings
|
||||
{
|
||||
[CommandArgument(1, "[Bar]")]
|
||||
public string Bar { get; set; }
|
||||
|
||||
[CommandArgument(0, "<Foos>")]
|
||||
public string[] Foo { get; set; }
|
||||
|
||||
[CommandArgument(1, "<Bar>")]
|
||||
public string Bar { get; set; }
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user