API Reference
Class
Prompt
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:
BooleanAsks a yes/no question.
Parameters
- title System.String
- The question.
- defaultValue System.Boolean? = null
- The default answer, or null.
- options ConsoleMonster.Interactive.InteractiveOptions? = null
- Options.
- cancellationToken System.Threading.CancellationToken = default
- 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
- The question.
- defaultValue System.Boolean? = null
- The default answer, or null.
- options ConsoleMonster.Interactive.InteractiveOptions? = null
- Options.
- cancellationToken System.Threading.CancellationToken = default
- 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:
Int32Asks for a whole number.
Parameters
- title System.String
- The question.
- defaultValue System.Int32? = null
- The default, or null.
- minimum System.Int32? = null
- The smallest value, or null.
- maximum System.Int32? = null
- The largest value, or null.
- options ConsoleMonster.Interactive.InteractiveOptions? = null
- Options.
- cancellationToken System.Threading.CancellationToken = default
- 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
- The question.
- values System.Collections.Generic.IEnumerable<T?>
- The values.
- display System.Func<T?, System.String>? = null
- The title of a value; null uses its text.
- group System.Func<T?, System.String?>? = null
- The group of a value; null for none.
- options ConsoleMonster.Interactive.InteractiveOptions? = null
- Options.
- cancellationToken System.Threading.CancellationToken = default
- 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:
DecimalAsks for a number.
Parameters
- title System.String
- The question.
- defaultValue System.Decimal? = null
- The default, or null.
- minimum System.Decimal? = null
- The smallest value, or null.
- maximum System.Decimal? = null
- The largest value, or null.
- options ConsoleMonster.Interactive.InteractiveOptions? = null
- Options.
- cancellationToken System.Threading.CancellationToken = default
- 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:
StringAsks for a file or folder path.
Parameters
- title System.String
- The question.
- kind ConsoleMonster.Interactive.PathKind = Any
- What is accepted.
- mustExist System.Boolean = false
- Whether the path must exist.
- options ConsoleMonster.Interactive.InteractiveOptions? = null
- Options.
- cancellationToken System.Threading.CancellationToken = default
- Cancels the prompt.
Returns
The path as typed.
public static String Secret(String title, InteractiveOptions? options = null, CancellationToken cancellationToken = default) #Returns:
StringAsks for a secret (masked).
Parameters
- title System.String
- The question.
- options ConsoleMonster.Interactive.InteractiveOptions? = null
- Options.
- cancellationToken System.Threading.CancellationToken = default
- 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
- The question.
- values System.Collections.Generic.IEnumerable<T?>
- The values.
- display System.Func<T?, System.String>? = null
- The title of a value; null uses its text.
- options ConsoleMonster.Interactive.InteractiveOptions? = null
- Options.
- cancellationToken System.Threading.CancellationToken = default
- 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
- The question.
- values System.Collections.Generic.IEnumerable<T?>
- The values.
- display System.Func<T?, System.String>? = null
- The title of a value; null uses its text.
- options ConsoleMonster.Interactive.InteractiveOptions? = null
- Options.
- cancellationToken System.Threading.CancellationToken = default
- 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:
StringAsks for a line of text.
Parameters
- title System.String
- The question.
- defaultValue System.String? = null
- The default, or null.
- validator System.Func<System.String, System.String?>? = null
- Returns an error message, or null when the answer is fine.
- options ConsoleMonster.Interactive.InteractiveOptions? = null
- Options.
- cancellationToken System.Threading.CancellationToken = default
- Cancels the prompt.
Returns
The answer.
public static Boolean TypedConfirm(String title, String expected, InteractiveOptions? options = null, CancellationToken cancellationToken = default) #Returns:
BooleanAsks the user to type a text before a destructive action.
Parameters
- title System.String
- The question.
- expected System.String
- The text to type.
- options ConsoleMonster.Interactive.InteractiveOptions? = null
- Options.
- cancellationToken System.Threading.CancellationToken = default
- Cancels the prompt.
Returns
True when confirmed.
Inherited Methods
public virtual Boolean Equals(Object? obj) #Returns:
BooleanInherited from Object
Parameters
- obj Object?