private static void OperateInteractive() { // list our tools var tools = ListTools(); string line = "help"; do { switch (line) { case "help": case "h": Console.WriteLine("exit: Quit"); Console.WriteLine("help: Print this help"); int i = 0; foreach (var tool in tools) { Console.WriteLine("{0}: {1}", i++, tool.Name); } break; case "exit": case "quit": case "e": case "q": return; default: try { IDevTool tool = tools.ElementAt(Int32.Parse(line)); tool.OutputStream = (TextWriter)Console.Out; if (tool is IQuestioningDevTool) { (tool as IQuestioningDevTool).Answers = new Dictionary <string, string>(); foreach (var question in (tool as IQuestioningDevTool).Questions) { Console.Write(question.Text); (tool as IQuestioningDevTool).Answers[question.Name] = Console.ReadLine(); } } tool.Run(); } catch (ArgumentOutOfRangeException) { Console.WriteLine("Tool {0} not found", Int32.Parse(line)); } catch (FormatException) { Console.WriteLine("Invalid command"); } break; } Console.WriteLine(""); Console.Write("DevTool> "); line = Console.ReadLine().Trim(); } while (line != "q" && line != "quit"); }
static void Main(string[] args) { if (Installation.GetFileLayoutType() == FileLayoutType.Source) { Console.WriteLine("DevTool only works from a source tree"); Environment.Exit(1); } var tools = new IDevTool[] { new InterfaceCheck(), new DocGen.DocDevTool(), new WixFSGenerator() }; string line = "help"; do { switch (line) { case "help": case "h": Console.WriteLine("exit: Quit"); Console.WriteLine("help: Print this help"); int i = 0; foreach (var tool in tools) { Console.WriteLine("{0}: {1}", i++, tool.Name); } break; case "exit": case "quit": case "e": case "q": return; default: try { IDevTool tool = tools.ElementAt(Int32.Parse(line)); tool.OutputStream = (TextWriter)Console.Out; tool.InputStream = (TextReader)Console.In; tool.Run(); } catch (ArgumentOutOfRangeException) { Console.WriteLine("Tool {0} not found", Int32.Parse(line)); } catch (FormatException) { Console.WriteLine("Invalid command"); } break; } Console.WriteLine(""); Console.Write("DevTool> "); line = Console.ReadLine().Trim(); } while (line != "q" && line != "quit"); }