public static IEnumerable <ICommand> NextCommand() { while (true) { yield return(CommandHandlerFactory.Create(Output.ReadLine())); } }
private static void PerformCommand() { if (CommandIsNotAllowed()) { return; } CommandExecutionResult result = null; try { result = CommandHandlerFactory .Create(_executionContext.Command.CommandType) .Execute(_executionContext.Command.Parameters, _executionContext.CurrentScreen.Model); } catch (Exception exception) { ExceptionScreen(exception); return; } _executionContext.CurrentScreen = result.NextScreenType.HasValue ? ScreenFactory.CreateScreen(_render, result.NextScreenType.Value, result.Model) : null; _executionContext.Command = null; _render.Clear(); }
public async Task run(string[] args) { var types = LoadTypes(); await Parser.Default.ParseArguments(args, types) .MapResult( (dynamic opts) => _factory.Create(opts).RunCommand(opts), err => Decimal.MinusOne); }
public void CreatesHandler() { object testResult = new object(); CommandHandlerFactory testSubject = new CommandHandlerFactory(t => testResult); object result = testSubject.Create(typeof(string)); Assert.Same(testResult, result); }
static void Main(string[] args) { var command = new Command(); bool isHelp = args.Any(x => x == "-?"); var success = Parser.Default.ParseArguments(args, command); if (!success || isHelp) { if (!isHelp && args.Length > 0) { Console.Error.WriteLine("error parsing command line"); } } var factory = new CommandHandlerFactory(); var commandHandler = factory.Create(command); commandHandler.Execute(command); }
private void ExecuteCommand(ConsoleCommand command) => _commandHandlerFactory .Create(command.Name) .Execute(command.Path);