public int Eval(string subcommand) { subcommand = subcommand.Trim(); var inputParts = subcommand.Split(" ", StringSplitOptions.RemoveEmptyEntries); if (inputParts.Length > 0) { if (inputParts[0].Equals(Name)) { Console.WriteLine("Tricky."); return(0); } else { return(dispatcher.Eval(inputParts.Concat(Name).Join(" "))); } } else { foreach (var kvp in this.commandsByName) { Console.WriteLine(kvp.Key); } return(0); } }
public int Eval(string args) { foreach (var s in commands) { dispatcher.Eval(s); } return(0); }
public void Run() { while (true) { Console.Write("$ "); var input = Console.ReadLine(); try { dispatcher.Eval(input); } catch (CommandDispatchException e) { Console.WriteLine(e.Message); } Console.WriteLine(); } }
public int Run() { int ctrlCCount = 0; while (true) { Console.Write("> "); var input = ReadLineCancellable(); if (input != null) { ctrlCCount = 0; } else { ctrlCCount++; if (ctrlCCount == 2) { Console.WriteLine("Ctrl+C one more time to exit."); } else if (ctrlCCount == 3) { return(1); } } if (!string.IsNullOrWhiteSpace(input)) { try { dispatcher.Eval(input); } catch (Exception e) { Console.Error.WriteLine(e.Message); Console.Error.WriteLine(e.StackTrace); } Console.WriteLine(); } } }