Implemented AddAsyncDelegate (#766)

This commit is contained in:
Ignacio Calvo
2023-05-25 12:31:01 +02:00
committed by GitHub
parent 0ec70a44db
commit 35ce60b596
13 changed files with 859 additions and 675 deletions

View File

@ -1,14 +1,14 @@
namespace Spectre.Console.Cli;
internal sealed class CommandInfo : ICommandContainer
{
{
public string Name { get; }
public HashSet<string> Aliases { get; }
public string? Description { get; }
public object? Data { get; }
public Type? CommandType { get; }
public Type SettingsType { get; }
public Func<CommandContext, CommandSettings, int>? Delegate { get; }
public Func<CommandContext, CommandSettings, Task<int>>? Delegate { get; }
public bool IsDefaultCommand { get; }
public CommandInfo? Parent { get; }
public IList<CommandInfo> Children { get; }
@ -16,11 +16,11 @@ internal sealed class CommandInfo : ICommandContainer
public IList<string[]> Examples { get; }
public bool IsBranch => CommandType == null && Delegate == null;
IList<CommandInfo> ICommandContainer.Commands => Children;
IList<CommandInfo> ICommandContainer.Commands => Children;
// only branches can have a default command
public CommandInfo? DefaultCommand => IsBranch ? Children.FirstOrDefault(c => c.IsDefaultCommand) : null;
public bool IsHidden { get; }
public CommandInfo? DefaultCommand => IsBranch ? Children.FirstOrDefault(c => c.IsDefaultCommand) : null;
public bool IsHidden { get; }
public CommandInfo(CommandInfo? parent, ConfiguredCommand prototype)
{