44 lines
1.2 KiB
C#
44 lines
1.2 KiB
C#
using NozCli.Commands;
|
|
|
|
namespace NozCli.Repl;
|
|
|
|
public class CommandRegistry
|
|
{
|
|
private readonly Dictionary<string, ICommand> _map;
|
|
|
|
public IReadOnlyList<ICommand> All { get; }
|
|
|
|
public CommandRegistry()
|
|
{
|
|
var list = new List<ICommand>
|
|
{
|
|
new LsCommand(),
|
|
new CdCommand(),
|
|
new CatCommand(),
|
|
new NewCommand(),
|
|
new EditCommand(),
|
|
new PushCommand(),
|
|
new SyncCommand(),
|
|
new StatusCommand(),
|
|
new RmCommand(),
|
|
new ConfigCommand(),
|
|
new TreeCommand(),
|
|
new MkdirCommand(),
|
|
new MvCommand(),
|
|
new SearchCommand(),
|
|
new LinkCommand(),
|
|
new TemplatesCommand(),
|
|
new VersionCommand(),
|
|
new ClearCommand(),
|
|
};
|
|
// HelpCommand gets the full list so it can print them all
|
|
list.Add(new HelpCommand(list));
|
|
|
|
All = list.AsReadOnly();
|
|
_map = list.ToDictionary(c => c.Name, StringComparer.OrdinalIgnoreCase);
|
|
}
|
|
|
|
public ICommand? Find(string name) => _map.GetValueOrDefault(name);
|
|
|
|
public IEnumerable<string> Names => _map.Keys;
|
|
}
|