Beispiel #1
0
        public string Show(string message)
        {
            CLIConsole.WriteLine(message, PromptConfig.PromptColor);
            while (true)
            {
                CLIConsole.Write(">");
                var input = Console.ReadLine();
                if (input.Length > 0)
                {
                    return(input);
                }

                CLIConsole.WriteLine("type any word.", PromptConfig.PromptColor);
            }
        }
Beispiel #2
0
 public (bool, string) ShowQuitable(string message)
 {
     CLIConsole.WriteLine(message, ConsoleColor.Magenta);
     while (true)
     {
         CLIConsole.Write(">");
         var rawInput = Console.ReadLine();
         var input    = rawInput.ToLower().Trim();
         if (input.Length > 0)
         {
             var isQuit = input == "q" || input == "quit";
             return(isQuit, rawInput);
         }
         CLIConsole.WriteLine("type any word.", PromptConfig.PromptColor);
     }
 }
Beispiel #3
0
        public Result Show(string message, Result?optResult = Result.Yes)
        {
            string promptText;

            if (optResult.HasValue)
            {
                promptText = optResult.Value == Result.Yes ? "[y] >" : "[n] >";
            }
            else
            {
                promptText = ">";
            }

            CLIConsole.Write(message, PromptConfig.PromptColor);
            CLIConsole.WriteLine("(y/n)");
            CLIConsole.Write(promptText);
            while (true)
            {
                var rawInput = Console.ReadLine();
                var input    = rawInput.ToLower().Trim();
                if (optResult.HasValue && input == "")
                {
                    var result = optResult.Value;
                    return(result);
                }

                switch (input)
                {
                case "y":
                case "yes":
                    return(Result.Yes);

                case "n":
                case "no":
                    return(Result.No);
                }

                CLIConsole.WriteLine("type 'y' or 'n'");
                CLIConsole.Write(promptText);
            }
        }