Prompt<T>
ConsoleMonster.Interactive
The base of every prompt. Prompt<T>.Show picks the interaction mode: a rich inline prompt (or an overlay over a running live dashboard), a line-based question, an accessible numbered question, or, when nobody can answer, the default or a clear PromptUnavailableException. It never waits for input that cannot come.
Inheritance
- object
- Prompt<T>
Usage
Explore 2 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 1
- Method Question.Text
Accepted by parameters 1
- Method MenuContext.Ask``1
Type Parameters
- T
- The answer type.
Methods
public abstract string Describe(T? value) #The answer as text, for the summary line left in the scrollback.
Parameters
- value T?
- The answer.
Returns
string The text.public virtual T? Show(InteractiveOptions? options = null, CancellationToken cancellationToken = default) #Asks the question and returns the answer.
Parameters
- options ConsoleMonster.Interactive.InteractiveOptions? = null
- Options; null uses InteractiveOptions.Default.
- cancellationToken System.Threading.CancellationToken = default
- Cancels the prompt.
Returns
T? The answer.Exceptions
PromptCanceledException– The user cancelled.PromptUnavailableException– Nobody can answer and there is no default.
public Task<T?> ShowAsync(InteractiveOptions? options = null, CancellationToken cancellationToken = default) #Asks the question on a worker thread.
Parameters
- options ConsoleMonster.Interactive.InteractiveOptions? = null
- Options.
- cancellationToken System.Threading.CancellationToken = default
- Cancels the prompt.
Returns
Task<T?> The answer.public IWidget Snapshot(InteractiveOptions? options = null) #Builds the initialized rich prompt as a widget without reading input or producing an answer.
Parameters
- options ConsoleMonster.Interactive.InteractiveOptions? = null
- Profile, theme, labels and inline height; null uses the interactive defaults. Input and mode are not used.
Returns
IWidget The prompt's initial view, suitable for ordinary terminal output or a documentation layout.public bool TryShow(out T? value, InteractiveOptions? options = null, CancellationToken cancellationToken = default) #Asks the question; returns false instead of throwing when the user cancels.
Parameters
- value T?
- The answer.
- options ConsoleMonster.Interactive.InteractiveOptions? = null
- Options.
- cancellationToken System.Threading.CancellationToken = default
- Cancels the prompt.
Returns
bool Whether an answer was given.