TextPromptExtensions

Contains extension methods for .

Contains extension methods for TextPrompt.

Methods

public static TextPrompt<T> AddChoice<T>(TextPrompt<T> obj, T choice)

Adds a choice to the prompt.

Parameters:

obj (TextPrompt<T>)
The prompt.
choice (T)
The choice to add.

Returns:

The same instance so that multiple calls can be chained.

public static TextPrompt<T> AddChoices<T>(TextPrompt<T> obj, IEnumerable<T> choices)

Adds multiple choices to the prompt.

Parameters:

obj (TextPrompt<T>)
The prompt.
choices (IEnumerable<T>)
The choices to add.

Returns:

The same instance so that multiple calls can be chained.

public static TextPrompt<T> AllowEmpty<T>(TextPrompt<T> obj)

Allow empty input.

Parameters:

obj (TextPrompt<T>)
The prompt.

Returns:

The same instance so that multiple calls can be chained.

public static TextPrompt<T> ClearOnFinish<T>(TextPrompt<T> obj, bool clear = true)

Clears the prompt line after successful input.

Parameters:

obj (TextPrompt<T>)
The prompt.
clear (bool)
Whether the prompt line should be cleared

Returns:

The same instance so that multiple calls can be chained.

public static TextPrompt<T> DefaultValue<T>(TextPrompt<T> obj, T value)

Sets the default value of the prompt.

Parameters:

obj (TextPrompt<T>)
The prompt.
value (T)
The default value.

Returns:

The same instance so that multiple calls can be chained.

public static TextPrompt<T> EditableDefaultValue<T>(TextPrompt<T> obj, bool state)

Whether or not to write the default value in the text input field to be modified by the end user.

Parameters:

obj (TextPrompt<T>)
The prompt.
state (bool)
Whether or not the default value should be editable.

Returns:

The same instance so that multiple calls can be chained.

public static TextPrompt<T> HideChoices<T>(TextPrompt<T> obj)

Hides choices.

Parameters:

obj (TextPrompt<T>)
The prompt.

Returns:

The same instance so that multiple calls can be chained.

public static TextPrompt<T> HideDefaultValue<T>(TextPrompt<T> obj)

Hides the default value.

Parameters:

obj (TextPrompt<T>)
The prompt.

Returns:

The same instance so that multiple calls can be chained.

public static TextPrompt<T> InvalidChoiceMessage<T>(TextPrompt<T> obj, string message)

Sets the "invalid choice" message for the prompt.

Parameters:

obj (TextPrompt<T>)
The prompt.
message (string)
The "invalid choice" message.

Returns:

The same instance so that multiple calls can be chained.

public static TextPrompt<T> Secret<T>(TextPrompt<T> obj)

Replaces prompt user input with asterisks in the console.

Parameters:

obj (TextPrompt<T>)
The prompt.

Returns:

The same instance so that multiple calls can be chained.

public static TextPrompt<T> Secret<T>(TextPrompt<T> obj, char? mask)

Replaces prompt user input with mask in the console.

Parameters:

obj (TextPrompt<T>)
The prompt.
mask (char?)
The masking character to use for the secret.

Returns:

The same instance so that multiple calls can be chained.

public static TextPrompt<T> ShowChoices<T>(TextPrompt<T> obj, bool show)

Show or hide choices.

Parameters:

obj (TextPrompt<T>)
The prompt.
show (bool)
Whether or not choices should be visible.

Returns:

The same instance so that multiple calls can be chained.

public static TextPrompt<T> ShowChoices<T>(TextPrompt<T> obj)

Shows choices.

Parameters:

obj (TextPrompt<T>)
The prompt.

Returns:

The same instance so that multiple calls can be chained.

public static TextPrompt<T> ShowDefaultValue<T>(TextPrompt<T> obj, bool show)

Show or hide the default value.

Parameters:

obj (TextPrompt<T>)
The prompt.
show (bool)
Whether or not the default value should be visible.

Returns:

The same instance so that multiple calls can be chained.

public static TextPrompt<T> ShowDefaultValue<T>(TextPrompt<T> obj)

Shows the default value.

Parameters:

obj (TextPrompt<T>)
The prompt.

Returns:

The same instance so that multiple calls can be chained.

public static TextPrompt<T> Validate<T>(TextPrompt<T> obj, Func<T, bool> validator, string message = null)

Sets the validation criteria for the prompt.

Parameters:

obj (TextPrompt<T>)
The prompt.
validator (Func<T, bool>)
The validation criteria.
message (string)
The validation error message.

Returns:

The same instance so that multiple calls can be chained.

public static TextPrompt<T> Validate<T>(TextPrompt<T> obj, Func<T, ValidationResult> validator)

Sets the validation criteria for the prompt.

Parameters:

obj (TextPrompt<T>)
The prompt.
validator (Func<T, ValidationResult>)
The validation criteria.

Returns:

The same instance so that multiple calls can be chained.

public static TextPrompt<T> ValidationErrorMessage<T>(TextPrompt<T> obj, string message)

Sets the validation error message for the prompt.

Parameters:

obj (TextPrompt<T>)
The prompt.
message (string)
The validation error message.

Returns:

The same instance so that multiple calls can be chained.

public static TextPrompt<T> WithConverter<T>(TextPrompt<T> obj, Func<T, string> displaySelector)

Sets the function to create a display string for a given choice.

Parameters:

obj (TextPrompt<T>)
The prompt.
displaySelector (Func<T, string>)
The function to get a display string for a given choice.

Returns:

The same instance so that multiple calls can be chained.