public void Eval(params string[] input) { if (input.IsNullOrEmpty()) { return; } string commandName = input.First(); CommandDef cmd = this[commandName]; if (cmd == null) { this.ShowUsageCommandNotFound(commandName); return; } try { cmd.Eval((input.Select(arg => arg)).Skip(1).ToArray()); } catch (Exception ex) { this.HandleError(ex); CommandUI.PrintSectionBreak(); cmd.ShowUsage(); } }
void ShowAllUsage() { CommandUI.PrintHeading("Registered commands"); foreach (string name in this.CommandNames) { this.ShowUsage(name); } }
internal void ShowUsage() { CommandUI.PrintUpperCase(this.Name); if (this.UsageFunctor != null) { Console.WriteLine(this.UsageFunctor()); } Console.WriteLine(); }
void HandleError(Exception ex) { if (this.Error != null) { this.Error(ex); } else { CommandUI.Print(ex); } }
public void RunInteractive() { CommandUI.PrintHeading(m_appName); string input; while ((input = CommandUI.GetInput()) != null) { if (input.Length > 0) { this.Run(input); } } }
void ShowUsageCommandNotFound(string commandName) { Console.WriteLine(); CommandUI.PrintUpperCase("{0}: No such command.", commandName); CommandUI.PrintSectionBreak(); // // Speculatively print out names of commands with this prefix.. // if (this.PrefixMatchCommandNames(commandName).FirstOrDefault() != null) { // // Speculatively print out names of commands with this prefix.. // CommandUI.PrintHeading("Did you mean?"); this.ListCommands(new string[] { commandName }); } else { Console.WriteLine(HelpUsage); } }
internal void ShowCommand() { CommandUI.PrintUpperCase(this.Name); }