private InputModel build(params string[] tokens) { var queue = new Queue <string>(tokens); var graph = new UsageGraph("fubu", typeof(InputCommand)); return((InputModel)graph.BuildInput(queue)); }
private CommandRun buildRun(Queue <string> queue, string commandName) { var usages = new UsageGraph(_commandTypes[commandName]); try { var input = usages.BuildInput(queue, _commandCreator); BeforeBuild?.Invoke(commandName, input); var command = Build(commandName); var run = new CommandRun { Command = command, Input = input }; ConfigureRun(run); return(run); } catch (InvalidUsageException e) { ConsoleWriter.Write(ConsoleColor.Red, "Invalid usage"); if (e.Message.IsNotEmpty()) { ConsoleWriter.Write(ConsoleColor.Yellow, e.Message); } Console.WriteLine(); } catch (Exception e) { ConsoleWriter.Write(ConsoleColor.Red, "Error parsing input"); ConsoleWriter.Write(ConsoleColor.Yellow, e.ToString()); Console.WriteLine(); } return(HelpRun(commandName)); }