TextPrompt
ConsoleMonster.Interactive
A line of text: a default (shown as a hint, accepted with Enter on an empty line, Tab puts it in the box to edit), a placeholder, required/length/pattern checks and a custom validator with an inline error, and history on Up/Down.
Inheritance
- Prompt<string>
- TextPrompt
Usage
Explore 52 API references to this type
This type appears in these public API surfaces even when no hand-authored example is attached directly to the page.
Returned or exposed by 26
- Extension method TextPrompt.Default
- Extension method TextPrompt.Description
- Extension method TextPrompt.History
- Extension method TextPrompt.MaxLength
- Extension method TextPrompt.MinLength
- Extension method TextPrompt.ParameterName
- Extension method TextPrompt.Pattern
- Extension method TextPrompt.PatternMessage
- Extension method TextPrompt.Placeholder
- Extension method TextPrompt.PrefillDefault
- Extension method TextPrompt.Required
- Extension method TextPrompt.Title
- Extension method TextPrompt.Validate
- Method TextPromptFluent.Default
- Method TextPromptFluent.Description
- Method TextPromptFluent.History
- Method TextPromptFluent.MaxLength
- Method TextPromptFluent.MinLength
- Method TextPromptFluent.ParameterName
- Method TextPromptFluent.Pattern
- Method TextPromptFluent.PatternMessage
- Method TextPromptFluent.Placeholder
- Method TextPromptFluent.PrefillDefault
- Method TextPromptFluent.Required
- Method TextPromptFluent.Title
- Method TextPromptFluent.Validate
Accepted by parameters 26
- Extension method TextPrompt.Default
- Extension method TextPrompt.Description
- Extension method TextPrompt.History
- Extension method TextPrompt.MaxLength
- Extension method TextPrompt.MinLength
- Extension method TextPrompt.ParameterName
- Extension method TextPrompt.Pattern
- Extension method TextPrompt.PatternMessage
- Extension method TextPrompt.Placeholder
- Extension method TextPrompt.PrefillDefault
- Extension method TextPrompt.Required
- Extension method TextPrompt.Title
- Extension method TextPrompt.Validate
- Method TextPromptFluent.Default
- Method TextPromptFluent.Description
- Method TextPromptFluent.History
- Method TextPromptFluent.MaxLength
- Method TextPromptFluent.MinLength
- Method TextPromptFluent.ParameterName
- Method TextPromptFluent.Pattern
- Method TextPromptFluent.PatternMessage
- Method TextPromptFluent.Placeholder
- Method TextPromptFluent.PrefillDefault
- Method TextPromptFluent.Required
- Method TextPromptFluent.Title
- Method TextPromptFluent.Validate
Constructors
Methods
public override string Describe(string value) #The answer as text, for the summary line left in the scrollback.
Parameters
- value string
- The answer.
Returns
string The text.Inherited Methods
public virtual string Show(InteractiveOptions? options = null, CancellationToken cancellationToken = default) #Parameters
- options InteractiveOptions? = null
- cancellationToken CancellationToken = default
Returns
stringpublic Task<string> ShowAsync(InteractiveOptions? options = null, CancellationToken cancellationToken = default) #Parameters
- options InteractiveOptions? = null
- cancellationToken CancellationToken = default
Returns
Task<string>public IWidget Snapshot(InteractiveOptions? options = null) #Parameters
- options InteractiveOptions? = null
Returns
IWidgetpublic bool TryShow(out string value, InteractiveOptions? options = null, CancellationToken cancellationToken = default) #Parameters
- value string
- options InteractiveOptions? = null
- cancellationToken CancellationToken = default
Returns
boolProperties
public bool Required { get; set; } #Whether an empty answer is refused (when there is no default).
public string? PatternMessage { get; set; } #The message when TextPrompt.Pattern does not match.
public Func<string, string?>? Validator { get; set; } #Fluent("Validate")A validator: returns an error message, or null when the answer is fine.
public IList<string> History { get; } #Earlier answers offered with Up and Down (oldest first).
public bool PrefillDefault { get; set; } #Starts with the default in the box (editable) instead of showing it as a hint.
Inherited Properties
public string Title { get; set; } #public string? Description { get; set; } #public string? ParameterName { get; set; } #public bool HasDefault { get; } #Extension Methods
public static TextPrompt Default(TextPrompt textPrompt, string value) #Sets Prompt<string>.Default: The default answer: pre-selected, accepted with Enter, and returned in non-interactive sessions.
Parameters
- textPrompt ConsoleMonster.Interactive.TextPrompt
- The instance.
- value string
- The value.
Examples
// C# initializer or property // C# fluent
textPrompt.Default = value; textPrompt.Default(value);public static TextPrompt Description(TextPrompt textPrompt, string? value) #Sets Prompt<string>.Description: Help text under the question.
Parameters
- textPrompt ConsoleMonster.Interactive.TextPrompt
- The instance.
- value string?
- The value.
Examples
// C# initializer or property // C# fluent
textPrompt.Description = value; textPrompt.Description(value);public static TextPrompt History(TextPrompt textPrompt, string item) #Adds an item to TextPrompt.History: Earlier answers offered with Up and Down (oldest first).
Parameters
- textPrompt ConsoleMonster.Interactive.TextPrompt
- The instance.
- item string
- The item.
public static TextPrompt History(TextPrompt textPrompt, IEnumerable<string> items) #Adds items to TextPrompt.History: Earlier answers offered with Up and Down (oldest first).
Parameters
- textPrompt ConsoleMonster.Interactive.TextPrompt
- The instance.
- items System.Collections.Generic.IEnumerable<string>
- The items, in order.
public static TextPrompt MaxLength(TextPrompt textPrompt, int value) #Sets TextPrompt.MaxLength: The most characters the box takes.
Parameters
- textPrompt ConsoleMonster.Interactive.TextPrompt
- The instance.
- value int
- The value.
Examples
// C# initializer or property // C# fluent
textPrompt.MaxLength = value; textPrompt.MaxLength(value);public static TextPrompt MinLength(TextPrompt textPrompt, int value) #Sets TextPrompt.MinLength: The fewest characters accepted.
Parameters
- textPrompt ConsoleMonster.Interactive.TextPrompt
- The instance.
- value int
- The value.
Examples
// C# initializer or property // C# fluent
textPrompt.MinLength = value; textPrompt.MinLength(value);public static TextPrompt ParameterName(TextPrompt textPrompt, string? value) #Sets Prompt<string>.ParameterName: The parameter that supplies this value non-interactively (-Domain, --domain); named in the non-interactive error message.
Parameters
- textPrompt ConsoleMonster.Interactive.TextPrompt
- The instance.
- value string?
- The value.
Examples
// C# initializer or property // C# fluent
textPrompt.ParameterName = value; textPrompt.ParameterName(value);public static TextPrompt Pattern(TextPrompt textPrompt, string? value) #Sets TextPrompt.Pattern: A pattern the whole answer must match.
Parameters
- textPrompt ConsoleMonster.Interactive.TextPrompt
- The instance.
- value string?
- The value.
Examples
// C# initializer or property // C# fluent
textPrompt.Pattern = value; textPrompt.Pattern(value);public static TextPrompt PatternMessage(TextPrompt textPrompt, string? value) #Sets TextPrompt.PatternMessage: The message when TextPrompt.Pattern does not match.
Parameters
- textPrompt ConsoleMonster.Interactive.TextPrompt
- The instance.
- value string?
- The value.
Examples
// C# initializer or property // C# fluent
textPrompt.PatternMessage = value; textPrompt.PatternMessage(value);public static TextPrompt Placeholder(TextPrompt textPrompt, string? value) #Sets TextPrompt.Placeholder: Muted text in the empty box.
Parameters
- textPrompt ConsoleMonster.Interactive.TextPrompt
- The instance.
- value string?
- The value.
Examples
// C# initializer or property // C# fluent
textPrompt.Placeholder = value; textPrompt.Placeholder(value);public static TextPrompt PrefillDefault(TextPrompt textPrompt, bool value = true) #Sets TextPrompt.PrefillDefault: Starts with the default in the box (editable) instead of showing it as a hint.
Parameters
- textPrompt ConsoleMonster.Interactive.TextPrompt
- The instance.
- value bool = true
- The value; true when omitted.
Examples
// C# initializer or property // C# fluent
textPrompt.PrefillDefault = value; textPrompt.PrefillDefault(value);public static TextPrompt Required(TextPrompt textPrompt, bool value = true) #Sets TextPrompt.Required: Whether an empty answer is refused (when there is no default).
Parameters
- textPrompt ConsoleMonster.Interactive.TextPrompt
- The instance.
- value bool = true
- The value; true when omitted.
Examples
// C# initializer or property // C# fluent
textPrompt.Required = value; textPrompt.Required(value);public static TextPrompt Title(TextPrompt textPrompt, string value) #Sets Prompt<string>.Title: The question.
Parameters
- textPrompt ConsoleMonster.Interactive.TextPrompt
- The instance.
- value string
- The value.
Examples
// C# initializer or property // C# fluent
textPrompt.Title = value; textPrompt.Title(value);public static TextPrompt Validate(TextPrompt textPrompt, Func<string, string?>? value) #Sets TextPrompt.Validator: A validator: returns an error message, or null when the answer is fine.
Parameters
- textPrompt ConsoleMonster.Interactive.TextPrompt
- The instance.
- value System.Func<string, string?>?
- The callback.
Examples
// C# initializer or property // C# fluent
textPrompt.Validator = value; textPrompt.Validate(value);