initial commit
This commit is contained in:
18
Commands/CommandRegistry.cs
Normal file
18
Commands/CommandRegistry.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
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;
|
||||
}
|
||||
Reference in New Issue
Block a user