public void FixtureSetup() { _inst = new MethorCommandIntegrationTest(); var catalog = new CommandsCatalog(); catalog.AddCommandsFrom <MethorCommandIntegrationTest>(); catalog.AddCommandsFrom(_inst); _dispatcher = new CommandDispatcher(catalog); }
public void When_two_commands_have_the_same_names_should_pick_the_first_one() { var catalog = new CommandsCatalog(); int value = 0; catalog.AddCommand(() => value = 1).WithName("cmd"); catalog.AddCommand(() => value = 2).WithName("cmd"); var dispacther = new CommandDispatcher(catalog); dispacther.DispatchCommand("cmd"); value.Should().Be(1); }
private static void Main(string[] args) { var manager = new TaskManager(); var catalog = new CommandsCatalog(); catalog.AddCommandsFrom(manager); catalog.AddHelpCommand().WithGroup("todo"); catalog.AddExitCommand().WithGroup("todo"); var dispatcher = new CommandDispatcher(catalog); catalog.AddCommandsFrom(new DebugCommands(dispatcher)); dispatcher.DispatchCommand("\"check example app\" -c -t CommandFramework -t Example"); dispatcher.StartDispatchingFromUserInput(); }
static void Main(string[] args) { var containerBuilder = new ContainerBuilder(); containerBuilder.RegisterType <Service>().SingleInstance(); containerBuilder.RegisterType <AddValue>(); var catalog = new CommandsCatalog(); catalog.AddCommand <AddValue>(); catalog.AddExitCommand(); catalog.AddHelpCommand(); var dispatcher = new CommandDispatcher(catalog); dispatcher.UseCommandContextFactory(new AutofacCommandContextFactory(containerBuilder.Build())); dispatcher.StartDispatchingFromUserInput(); }
public HelpCommand(CommandsCatalog catalog) { _catalog = catalog; }