mirror of
https://github.com/nsnail/spectre.console.git
synced 2025-08-03 20:45:34 +08:00
Move Spectre.Console.Cli to it's own package
This commit is contained in:

committed by
Patrik Svensson

parent
b600832e00
commit
36ca22ffac
21
src/Spectre.Console.Cli/Internal/DelegateCommand.cs
Normal file
21
src/Spectre.Console.Cli/Internal/DelegateCommand.cs
Normal file
@ -0,0 +1,21 @@
|
||||
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();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user