Skip to content
ConsoleMonster

API Reference

Class

Prompt

Namespace ConsoleMonster.Interactive
Assembly ConsoleMonster
Modifiers static

One-call prompts: Prompt.Select("Target", servers, s => s.Name), Prompt.Confirm("Continue?", true). For every option, build the prompt object (SelectPrompt, TextPrompt, …) and call Show.

Inheritance

  • Object
  • Prompt

Methods

public static Boolean Confirm(String title, Boolean? defaultValue = null, InteractiveOptions? options = null, CancellationToken cancellationToken = default) #
Returns: Boolean

Asks a yes/no question.

Parameters

title System.String requiredposition: 0
The question.
defaultValue System.Boolean? = null optionalposition: 1
The default answer, or null.
options ConsoleMonster.Interactive.InteractiveOptions? = null optionalposition: 2
Options.
cancellationToken System.Threading.CancellationToken = default optionalposition: 3
Cancels the prompt.

Returns

The answer.

public static Task<Boolean> ConfirmAsync(String title, Boolean? defaultValue = null, InteractiveOptions? options = null, CancellationToken cancellationToken = default) #
Returns: Task<Boolean>

Asks a yes/no question on a worker thread.

Parameters

title System.String requiredposition: 0
The question.
defaultValue System.Boolean? = null optionalposition: 1
The default answer, or null.
options ConsoleMonster.Interactive.InteractiveOptions? = null optionalposition: 2
Options.
cancellationToken System.Threading.CancellationToken = default optionalposition: 3
Cancels the prompt.

Returns

The answer.

public static Int32 Integer(String title, Int32? defaultValue = null, Int32? minimum = null, Int32? maximum = null, InteractiveOptions? options = null, CancellationToken cancellationToken = default) #
Returns: Int32

Asks for a whole number.

Parameters

title System.String requiredposition: 0
The question.
defaultValue System.Int32? = null optionalposition: 1
The default, or null.
minimum System.Int32? = null optionalposition: 2
The smallest value, or null.
maximum System.Int32? = null optionalposition: 3
The largest value, or null.
options ConsoleMonster.Interactive.InteractiveOptions? = null optionalposition: 4
Options.
cancellationToken System.Threading.CancellationToken = default optionalposition: 5
Cancels the prompt.

Returns

The number.

public static IReadOnlyList<T?> MultiSelect<T>(String title, IEnumerable<T?> values, Func<T?, String>? display = null, Func<T?, String?>? group = null, InteractiveOptions? options = null, CancellationToken cancellationToken = default) #
Returns: IReadOnlyList<T?>

Picks any number of values.

Type Parameters

T
The value type.

Parameters

title System.String requiredposition: 0
The question.
values System.Collections.Generic.IEnumerable<T?> requiredposition: 1
The values.
display System.Func<T?, System.String>? = null optionalposition: 2
The title of a value; null uses its text.
group System.Func<T?, System.String?>? = null optionalposition: 3
The group of a value; null for none.
options ConsoleMonster.Interactive.InteractiveOptions? = null optionalposition: 4
Options.
cancellationToken System.Threading.CancellationToken = default optionalposition: 5
Cancels the prompt.

Returns

The values in list order.

public static Decimal Number(String title, Decimal? defaultValue = null, Decimal? minimum = null, Decimal? maximum = null, InteractiveOptions? options = null, CancellationToken cancellationToken = default) #
Returns: Decimal

Asks for a number.

Parameters

title System.String requiredposition: 0
The question.
defaultValue System.Decimal? = null optionalposition: 1
The default, or null.
minimum System.Decimal? = null optionalposition: 2
The smallest value, or null.
maximum System.Decimal? = null optionalposition: 3
The largest value, or null.
options ConsoleMonster.Interactive.InteractiveOptions? = null optionalposition: 4
Options.
cancellationToken System.Threading.CancellationToken = default optionalposition: 5
Cancels the prompt.

Returns

The number.

public static String Path(String title, PathKind kind = Any, Boolean mustExist = false, InteractiveOptions? options = null, CancellationToken cancellationToken = default) #
Returns: String

Asks for a file or folder path.

Parameters

title System.String requiredposition: 0
The question.
kind ConsoleMonster.Interactive.PathKind = Any optionalposition: 1
What is accepted.
mustExist System.Boolean = false optionalposition: 2
Whether the path must exist.
options ConsoleMonster.Interactive.InteractiveOptions? = null optionalposition: 3
Options.
cancellationToken System.Threading.CancellationToken = default optionalposition: 4
Cancels the prompt.

Returns

The path as typed.

public static String Secret(String title, InteractiveOptions? options = null, CancellationToken cancellationToken = default) #
Returns: String

Asks for a secret (masked).

Parameters

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

Returns

The secret.

public static Task<T?> SelectAsync<T>(String title, IEnumerable<T?> values, Func<T?, String>? display = null, InteractiveOptions? options = null, CancellationToken cancellationToken = default) #
Returns: Task<T?>

Picks one value on a worker thread.

Type Parameters

T
The value type.

Parameters

title System.String requiredposition: 0
The question.
values System.Collections.Generic.IEnumerable<T?> requiredposition: 1
The values.
display System.Func<T?, System.String>? = null optionalposition: 2
The title of a value; null uses its text.
options ConsoleMonster.Interactive.InteractiveOptions? = null optionalposition: 3
Options.
cancellationToken System.Threading.CancellationToken = default optionalposition: 4
Cancels the prompt.

Returns

The value.

public static T? Select<T>(String title, IEnumerable<T?> values, Func<T?, String>? display = null, InteractiveOptions? options = null, CancellationToken cancellationToken = default) #
Returns: T?

Picks one value.

Type Parameters

T
The value type.

Parameters

title System.String requiredposition: 0
The question.
values System.Collections.Generic.IEnumerable<T?> requiredposition: 1
The values.
display System.Func<T?, System.String>? = null optionalposition: 2
The title of a value; null uses its text.
options ConsoleMonster.Interactive.InteractiveOptions? = null optionalposition: 3
Options.
cancellationToken System.Threading.CancellationToken = default optionalposition: 4
Cancels the prompt.

Returns

The value.

public static String Text(String title, String? defaultValue = null, Func<String, String?>? validator = null, InteractiveOptions? options = null, CancellationToken cancellationToken = default) #
Returns: String

Asks for a line of text.

Parameters

title System.String requiredposition: 0
The question.
defaultValue System.String? = null optionalposition: 1
The default, or null.
validator System.Func<System.String, System.String?>? = null optionalposition: 2
Returns an error message, or null when the answer is fine.
options ConsoleMonster.Interactive.InteractiveOptions? = null optionalposition: 3
Options.
cancellationToken System.Threading.CancellationToken = default optionalposition: 4
Cancels the prompt.

Returns

The answer.

public static Boolean TypedConfirm(String title, String expected, InteractiveOptions? options = null, CancellationToken cancellationToken = default) #
Returns: Boolean

Asks the user to type a text before a destructive action.

Parameters

title System.String requiredposition: 0
The question.
expected System.String requiredposition: 1
The text to type.
options ConsoleMonster.Interactive.InteractiveOptions? = null optionalposition: 2
Options.
cancellationToken System.Threading.CancellationToken = default optionalposition: 3
Cancels the prompt.

Returns

True when confirmed.