Represents a prompt.
Constructors
public TextPrompt`1(string prompt, StringComparer comparer = null)
Initializes a new instance of the TextPrompt class.
Parameters:
prompt (string)comparer (StringComparer)Properties
AllowEmpty
: boolGets or sets a value indicating whether or not an empty result is valid.
Choices
: List<T>Gets the list of choices.
ClearOnFinish
: boolGets or sets a value indicating whether the prompt line should be cleared after a successful input.
Converter
: Func<T, string>Gets or sets the converter to get the display string for a choice. By default the corresponding TypeConverter is used.
Culture
: CultureInfoGets or sets the culture to use when converting input to object.
EditableDefaultValue
: boolGets or sets the default value editable state that allows the injection of the DefaultValue in the text field. If true this places the DefaultValue in the input buffer which can then be edited by the user.
InvalidChoiceMessage
: stringGets or sets the message for invalid choices.
IsSecret
: boolGets or sets a value indicating whether input should be hidden in the console.
Mask
: char?Gets or sets the character to use while masking a secret prompt.
ShowChoices
: boolGets or sets a value indicating whether or not choices should be shown.
ShowDefaultValue
: boolGets or sets a value indicating whether or not default values should be shown.
ValidationErrorMessage
: stringGets or sets the validation error message.
Validator
: Func<T, ValidationResult>Gets or sets the validator.
Methods
public T Show(IAnsiConsole console)
Shows the prompt and requests input from the user.
Parameters:
console (IAnsiConsole)Returns:
The user input converted to the expected type.
public Task<T> ShowAsync(IAnsiConsole console, CancellationToken cancellationToken)
Shows the prompt asynchronously.
Parameters:
console (IAnsiConsole)cancellationToken (CancellationToken)Returns:
The prompt input result.
Extension Methods
TextPrompt<T> AllowEmpty<T>(this TextPrompt<T> obj)Allow empty input.
Returns:
The same instance so that multiple calls can be chained.