feat: add console command framework

This commit is contained in:
2026-08-22 19:39:17 +02:00
parent c95233b9f9
commit 9f742f396f
28 changed files with 282 additions and 0 deletions
@@ -0,0 +1,25 @@
using System.Collections.Generic;
using Game.Features.Console.Contracts;
using Game.Features.Console.Domain;
namespace Game.Features.Console.Application;
public sealed class CommandExecute(ICommandRegistry registry)
{
public CommandResult Execute(string input)
{
if (!CommandLineParser.TryParse(input, out string name, out IReadOnlyList<string> arguments))
{
return CommandResult.Fail("No command entered.");
}
if (!registry.TryGet(name, out ICommand command))
{
return CommandResult.Fail($"Unknown command: {name}");
}
CommandResult result = CommandArgValidator.Validate(command.Args, arguments);
return !result.Success ? result : command.Execute(new CommandArgValues(arguments));
}
}