mirror of
https://github.com/nsnail/spectre.console.git
synced 2025-05-05 17:12:52 +08:00
21 lines
559 B
C#
21 lines
559 B
C#
namespace Spectre.Console.Cli;
|
|
|
|
internal sealed class DelegateCommand : ICommand
|
|
{
|
|
private readonly Func<CommandContext, CommandSettings, int> _func;
|
|
|
|
public DelegateCommand(Func<CommandContext, CommandSettings, int> func)
|
|
{
|
|
_func = func;
|
|
}
|
|
|
|
public Task<int> Execute(CommandContext context, CommandSettings settings)
|
|
{
|
|
return Task.FromResult(_func(context, settings));
|
|
}
|
|
|
|
public ValidationResult Validate(CommandContext context, CommandSettings settings)
|
|
{
|
|
return ValidationResult.Success();
|
|
}
|
|
} |