Skip to content
ConsoleMonster

API Reference

Class

Prompt`1

Namespace ConsoleMonster.Interactive
Assembly ConsoleMonster
Modifiers abstract

The base of every prompt. Prompt.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`1

Usage

Explore 1 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.

Accepted by parameters 1

Type Parameters

T
The answer type.

Methods

public abstract String Describe(T? value) #
Returns: String

The answer as text, for the summary line left in the scrollback.

Parameters

value T? requiredposition: 0
The answer.

Returns

The text.

public T? Show(InteractiveOptions? options = null, CancellationToken cancellationToken = default) #
Returns: T?

Asks the question and returns the answer.

Parameters

options ConsoleMonster.Interactive.InteractiveOptions? = null optionalposition: 0
Options; null uses InteractiveOptions.Default.
cancellationToken System.Threading.CancellationToken = default optionalposition: 1
Cancels the prompt.

Returns

The answer.

Exceptions

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

Asks the question on a worker thread.

Parameters

options ConsoleMonster.Interactive.InteractiveOptions? = null optionalposition: 0
Options.
cancellationToken System.Threading.CancellationToken = default optionalposition: 1
Cancels the prompt.

Returns

The answer.

public Boolean TryShow(out T? value, InteractiveOptions? options = null, CancellationToken cancellationToken = default) #
Returns: Boolean

Asks the question; returns false instead of throwing when the user cancels.

Parameters

value T? requiredposition: 0
The answer.
options ConsoleMonster.Interactive.InteractiveOptions? = null optionalposition: 1
Options.
cancellationToken System.Threading.CancellationToken = default optionalposition: 2
Cancels the prompt.

Returns

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 Boolean 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.