mirror of
https://github.com/nsnail/spectre.console.git
synced 2025-04-16 00:42:51 +08:00

Shows help if the default command was called without any arguments but has required arguments. This way it does not hinder execution of a default command without any required arguments. When called without args: - Default command with required params -> Show help - Default command with required params and additional commands -> Show help including additional commands - Default command without required params -> Execute command
17 lines
461 B
C#
17 lines
461 B
C#
using Spectre.Console;
|
|
|
|
public class GreeterCommand : Command<OptionalArgumentWithDefaultValueSettings>
|
|
{
|
|
private readonly IAnsiConsole _console;
|
|
|
|
public GreeterCommand(IAnsiConsole console)
|
|
{
|
|
_console = console;
|
|
}
|
|
|
|
public override int Execute([NotNull] CommandContext context, [NotNull] OptionalArgumentWithDefaultValueSettings settings)
|
|
{
|
|
_console.WriteLine(settings.Greeting);
|
|
return 0;
|
|
}
|
|
} |