noz-cli/NozCli/Repl/CommandRegistry.cs
kryptomrx 1865a7ccc2 feat(commands): clear, config, version
- clear: clears terminal screen
- config: view and set editor / code-editor preferences
- version: print version and git hash (noz 0.1.0 (abc1234))
2026-05-16 23:21:06 +02:00

39 lines
1 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 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;
}