ReplInteractionChannelExtensions
Extension methods that compose on top of IReplInteractionChannel primitives.
- Kind:
Class - Namespace: Repl.Interaction
- Assembly:
Repl.Core - Source: src/Repl.Core/Interaction/ReplInteractionChannelExtensions.cs
Signature
Section titled “Signature”public static class ReplInteractionChannelExtensionsInheritance
Section titled “Inheritance”Methods
Section titled “Methods”AskEnumAsync<TEnum>(IReplInteractionChannel, string, string, TEnum?, AskOptions?)
Section titled “AskEnumAsync<TEnum>(IReplInteractionChannel, string, string, TEnum?, AskOptions?)”Prompts the user to select a value from an enum type.
Uses DescriptionAttribute or DisplayAttribute names when present,
otherwise humanizes the enum member name (CamelCase becomes Camel case).
public static ValueTask<TEnum> AskEnumAsync<TEnum>(this IReplInteractionChannel channel, string name, string prompt, TEnum? defaultValue = null, AskOptions? options = null) where TEnum : struct, EnumType Parameters
Section titled “Type Parameters”TEnum
Parameters
Section titled “Parameters”channel(IReplInteractionChannel)name(string)prompt(string)defaultValue(TEnum?)options(AskOptions)
Returns
Section titled “Returns”ValueTask<TEnum>
AskFlagsEnumAsync<TEnum>(IReplInteractionChannel, string, string, TEnum?, AskMultiChoiceOptions?)
Section titled “AskFlagsEnumAsync<TEnum>(IReplInteractionChannel, string, string, TEnum?, AskMultiChoiceOptions?)”Prompts the user to select one or more values from a [Flags] enum type.
public static ValueTask<TEnum> AskFlagsEnumAsync<TEnum>(this IReplInteractionChannel channel, string name, string prompt, TEnum? defaultValue = null, AskMultiChoiceOptions? options = null) where TEnum : struct, EnumType Parameters
Section titled “Type Parameters”TEnum
Parameters
Section titled “Parameters”channel(IReplInteractionChannel)name(string)prompt(string)defaultValue(TEnum?)options(AskMultiChoiceOptions)
Returns
Section titled “Returns”ValueTask<TEnum>
AskNumberAsync<T>(IReplInteractionChannel, string, string, T?, AskNumberOptions<T>?)
Section titled “AskNumberAsync<T>(IReplInteractionChannel, string, string, T?, AskNumberOptions<T>?)”Prompts the user for a typed numeric value with optional min/max bounds.
public static ValueTask<T> AskNumberAsync<T>(this IReplInteractionChannel channel, string name, string prompt, T? defaultValue = null, AskNumberOptions<T>? options = null) where T : struct, INumber<T>, IParsable<T>Type Parameters
Section titled “Type Parameters”T
Parameters
Section titled “Parameters”channel(IReplInteractionChannel)name(string)prompt(string)defaultValue(T?)options(AskNumberOptions<T>)
Returns
Section titled “Returns”ValueTask<T>
AskValidatedTextAsync(IReplInteractionChannel, string, string, Func<string, string?>, string?, AskOptions?)
Section titled “AskValidatedTextAsync(IReplInteractionChannel, string, string, Func<string, string?>, string?, AskOptions?)”Prompts the user for text with inline validation. Re-prompts until the validator
returns null (meaning valid).
public static ValueTask<string> AskValidatedTextAsync(this IReplInteractionChannel channel, string name, string prompt, Func<string, string?> validate, string? defaultValue = null, AskOptions? options = null)Parameters
Section titled “Parameters”channel(IReplInteractionChannel): The interaction channel.name(string): Prompt name.prompt(string): Prompt text.validate(Func<string, string>): Validator function. Returnsnullwhen the input is valid, or an error message string otherwise.defaultValue(string): Optional default value.options(AskOptions): Optional ask options.
Returns
Section titled “Returns”ValueTask<string> - The validated text.
ClearProgressAsync(IReplInteractionChannel, CancellationToken)
Section titled “ClearProgressAsync(IReplInteractionChannel, CancellationToken)”Clears any currently visible progress indicator.
public static ValueTask ClearProgressAsync(this IReplInteractionChannel channel, CancellationToken cancellationToken = default)Parameters
Section titled “Parameters”channel(IReplInteractionChannel)cancellationToken(CancellationToken)
Returns
Section titled “Returns”PressAnyKeyAsync(IReplInteractionChannel, string, CancellationToken)
Section titled “PressAnyKeyAsync(IReplInteractionChannel, string, CancellationToken)”Displays a message and waits for the user to press any key.
public static ValueTask PressAnyKeyAsync(this IReplInteractionChannel channel, string prompt = "Press any key to continue...", CancellationToken cancellationToken = default)Parameters
Section titled “Parameters”channel(IReplInteractionChannel)prompt(string)cancellationToken(CancellationToken)
Returns
Section titled “Returns”WriteErrorProgressAsync(IReplInteractionChannel, string, double?, string?, CancellationToken)
Section titled “WriteErrorProgressAsync(IReplInteractionChannel, string, double?, string?, CancellationToken)”Writes an error-state progress update.
public static ValueTask WriteErrorProgressAsync(this IReplInteractionChannel channel, string label, double? percent = null, string? details = null, CancellationToken cancellationToken = default)Parameters
Section titled “Parameters”channel(IReplInteractionChannel)label(string)percent(double?)details(string)cancellationToken(CancellationToken)
Returns
Section titled “Returns”WriteIndeterminateProgressAsync(IReplInteractionChannel, string, string?, CancellationToken)
Section titled “WriteIndeterminateProgressAsync(IReplInteractionChannel, string, string?, CancellationToken)”Writes an indeterminate progress update.
public static ValueTask WriteIndeterminateProgressAsync(this IReplInteractionChannel channel, string label, string? details = null, CancellationToken cancellationToken = default)Parameters
Section titled “Parameters”channel(IReplInteractionChannel)label(string)details(string)cancellationToken(CancellationToken)
Returns
Section titled “Returns”WriteNoticeAsync(IReplInteractionChannel, string, CancellationToken)
Section titled “WriteNoticeAsync(IReplInteractionChannel, string, CancellationToken)”Writes an informational user-facing notice.
public static ValueTask WriteNoticeAsync(this IReplInteractionChannel channel, string text, CancellationToken cancellationToken = default)Parameters
Section titled “Parameters”channel(IReplInteractionChannel)text(string)cancellationToken(CancellationToken)
Returns
Section titled “Returns”WriteProblemAsync(IReplInteractionChannel, string, string?, string?, CancellationToken)
Section titled “WriteProblemAsync(IReplInteractionChannel, string, string?, string?, CancellationToken)”Writes a user-facing problem summary.
public static ValueTask WriteProblemAsync(this IReplInteractionChannel channel, string summary, string? details = null, string? code = null, CancellationToken cancellationToken = default)Parameters
Section titled “Parameters”channel(IReplInteractionChannel)summary(string)details(string)code(string)cancellationToken(CancellationToken)
Returns
Section titled “Returns”WriteProgressAsync(IReplInteractionChannel, ReplProgressEvent, CancellationToken)
Section titled “WriteProgressAsync(IReplInteractionChannel, ReplProgressEvent, CancellationToken)”Writes a structured progress update.
public static ValueTask WriteProgressAsync(this IReplInteractionChannel channel, ReplProgressEvent progress, CancellationToken cancellationToken = default)Parameters
Section titled “Parameters”channel(IReplInteractionChannel)progress(ReplProgressEvent)cancellationToken(CancellationToken)
Returns
Section titled “Returns”WriteWarningAsync(IReplInteractionChannel, string, CancellationToken)
Section titled “WriteWarningAsync(IReplInteractionChannel, string, CancellationToken)”Writes a user-facing warning.
public static ValueTask WriteWarningAsync(this IReplInteractionChannel channel, string text, CancellationToken cancellationToken = default)Parameters
Section titled “Parameters”channel(IReplInteractionChannel)text(string)cancellationToken(CancellationToken)
Returns
Section titled “Returns”WriteWarningProgressAsync(IReplInteractionChannel, string, double?, string?, CancellationToken)
Section titled “WriteWarningProgressAsync(IReplInteractionChannel, string, double?, string?, CancellationToken)”Writes a warning-state progress update.
public static ValueTask WriteWarningProgressAsync(this IReplInteractionChannel channel, string label, double? percent = null, string? details = null, CancellationToken cancellationToken = default)Parameters
Section titled “Parameters”channel(IReplInteractionChannel)label(string)percent(double?)details(string)cancellationToken(CancellationToken)