19 lines
464 B
C#
19 lines
464 B
C#
namespace AnchorCli.Commands;
|
|
|
|
public class CommandRegistry
|
|
{
|
|
private readonly Dictionary<string, ICommand> _commands = new(StringComparer.OrdinalIgnoreCase);
|
|
|
|
public void Register(ICommand command)
|
|
{
|
|
_commands[command.Name] = command;
|
|
}
|
|
|
|
public ICommand? GetCommand(string name)
|
|
{
|
|
return _commands.TryGetValue(name, out var cmd) ? cmd : null;
|
|
}
|
|
|
|
public IEnumerable<ICommand> GetAllCommands() => _commands.Values;
|
|
}
|