Skip to content
ConsoleMonster
Class

Prompt<T>

ConsoleMonster.Interactive

Namespace
ConsoleMonster.Interactive
Assembly
ConsoleMonster
Modifiers
abstract
Attributes
Fluent

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

Accepted by parameters 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? required
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 optional
Options; null uses InteractiveOptions.Default.
cancellationToken System.Threading.CancellationToken = default optional
Cancels the prompt.

Returns

T? The answer.

Exceptions

public Task<T?> ShowAsync(InteractiveOptions? options = null, CancellationToken cancellationToken = default) #

Asks the question on a worker thread.

Parameters

options ConsoleMonster.Interactive.InteractiveOptions? = null optional
Options.
cancellationToken System.Threading.CancellationToken = default optional
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 optional
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? required
The answer.
options ConsoleMonster.Interactive.InteractiveOptions? = null optional
Options.
cancellationToken System.Threading.CancellationToken = default optional
Cancels the prompt.

Returns

bool Whether an answer was given.

Properties

public string Title { get; set; } #

The question.

public string? Description { get; set; } #

Help text under the question.

public string? ParameterName { get; set; } #

The parameter that supplies this value non-interactively (-Domain, --domain); named in the non-interactive error message.

public bool HasDefault { get; private set; } #

Whether a default was set.

public T? Default { get; set; } #

The default answer: pre-selected, accepted with Enter, and returned in non-interactive sessions.