Exemplo n.º 1
0
        public static Prompter BlankLine(this Prompter prompter, Action <StaticText> setupStaticText = null)
        {
            var staticText = new StaticText(new ColorString());

            setupStaticText?.Invoke(staticText);
            prompter.Add(staticText);
            return(prompter);
        }
Exemplo n.º 2
0
        public static Prompter Text(this Prompter prompter, FunctionOrColorString text,
                                    Action <StaticText> setupStaticText = null)
        {
            var staticText = new StaticText(text);

            setupStaticText?.Invoke(staticText);
            prompter.Add(staticText);
            return(prompter);
        }
Exemplo n.º 3
0
        public static Prompter Checkbox(this Prompter prompter, string name, FunctionOrColorString message,
                                        IEnumerable <string> choices, Action <CheckboxQuestion> setupQuestion = null)
        {
            var question = new CheckboxQuestion(name, message, choices);

            setupQuestion?.Invoke(question);
            prompter.Add(question);
            return(prompter);
        }
Exemplo n.º 4
0
        public static Prompter Confirm(this Prompter prompter, string name, FunctionOrColorString message,
                                       bool @default = false, Action <ConfirmQuestion> setupQuestion = null)
        {
            var question = new ConfirmQuestion(name, message, @default);

            setupQuestion?.Invoke(question);
            prompter.Add(question);
            return(prompter);
        }
Exemplo n.º 5
0
        public static Prompter Password(this Prompter prompter, string name, FunctionOrColorString message,
                                        Action <PasswordQuestion> setupQuestion = null)
        {
            var question = new PasswordQuestion(name, message);

            setupQuestion?.Invoke(question);
            prompter.Add(question);
            return(prompter);
        }
Exemplo n.º 6
0
        public static Prompter Separator(this Prompter prompter, char separator = '=',
                                         Action <StaticText> setupStaticText    = null)
        {
            var staticText = new StaticText(new ColorString(new string(separator, Console.WindowWidth)));

            setupStaticText?.Invoke(staticText);
            prompter.Add(staticText);
            return(prompter);
        }
Exemplo n.º 7
0
        //TODO: Enforce a converter parameter here
        public static Prompter List <TValue>(this Prompter prompter, string name, FunctionOrColorString message,
                                             IEnumerable <string> choices, Func <int, TValue> converter, Action <ListQuestion <TValue> > setupQuestion = null)
        {
            if (converter is null)
            {
                throw new ArgumentNullException(nameof(converter));
            }
            var question = new ListQuestion <TValue>(name, message, choices);

            question.Transform(converter);
            setupQuestion?.Invoke(question);
            prompter.Add(question);
            return(prompter);
        }