mirror of
https://github.com/nsnail/spectre.console.git
synced 2025-06-20 05:48:14 +08:00
Use file scoped namespace declarations
This commit is contained in:

committed by
Phil Scott

parent
1dbaf50935
commit
ec1188b837
@ -1,37 +1,36 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Spectre.Console.Cli
|
||||
namespace Spectre.Console.Cli;
|
||||
|
||||
internal sealed class CommandTree
|
||||
{
|
||||
internal sealed class CommandTree
|
||||
public CommandInfo Command { get; }
|
||||
public List<MappedCommandParameter> Mapped { get; }
|
||||
public List<CommandParameter> Unmapped { get; }
|
||||
public CommandTree? Parent { get; }
|
||||
public CommandTree? Next { get; set; }
|
||||
public bool ShowHelp { get; set; }
|
||||
|
||||
public CommandTree(CommandTree? parent, CommandInfo command)
|
||||
{
|
||||
public CommandInfo Command { get; }
|
||||
public List<MappedCommandParameter> Mapped { get; }
|
||||
public List<CommandParameter> Unmapped { get; }
|
||||
public CommandTree? Parent { get; }
|
||||
public CommandTree? Next { get; set; }
|
||||
public bool ShowHelp { get; set; }
|
||||
Parent = parent;
|
||||
Command = command;
|
||||
Mapped = new List<MappedCommandParameter>();
|
||||
Unmapped = new List<CommandParameter>();
|
||||
}
|
||||
|
||||
public CommandTree(CommandTree? parent, CommandInfo command)
|
||||
public ICommand CreateCommand(ITypeResolver resolver)
|
||||
{
|
||||
if (Command.Delegate != null)
|
||||
{
|
||||
Parent = parent;
|
||||
Command = command;
|
||||
Mapped = new List<MappedCommandParameter>();
|
||||
Unmapped = new List<CommandParameter>();
|
||||
return new DelegateCommand(Command.Delegate);
|
||||
}
|
||||
|
||||
public ICommand CreateCommand(ITypeResolver resolver)
|
||||
if (resolver.Resolve(Command.CommandType) is ICommand command)
|
||||
{
|
||||
if (Command.Delegate != null)
|
||||
{
|
||||
return new DelegateCommand(Command.Delegate);
|
||||
}
|
||||
|
||||
if (resolver.Resolve(Command.CommandType) is ICommand command)
|
||||
{
|
||||
return command;
|
||||
}
|
||||
|
||||
throw CommandParseException.CouldNotCreateCommand(Command.CommandType);
|
||||
return command;
|
||||
}
|
||||
|
||||
throw CommandParseException.CouldNotCreateCommand(Command.CommandType);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user