ChoiceField
ConsoleMonster.Interactive
One or several values from a list, given up front or loaded asynchronously from the values of the fields it depends on (choosing a site loads its servers): a spinner shows while loading, and loading can be cancelled.
Inheritance
- Field
- ChoiceField
Usage
Explore 68 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 36
- Extension method ChoiceField.Choice
- Extension method ChoiceField.Choices
- Extension method ChoiceField.ChoicesBy
- Extension method ChoiceField.Default
- Extension method ChoiceField.DependsOn
- Extension method ChoiceField.Help
- Extension method ChoiceField.Label
- Extension method ChoiceField.Maximum
- Extension method ChoiceField.Minimum
- Extension method ChoiceField.ParameterName
- Extension method ChoiceField.PreviewBy
- Extension method ChoiceField.Remember
- Extension method ChoiceField.Required
- Extension method ChoiceField.ShowWhen
- Extension method ChoiceField.Validate
- Extension method ChoiceField.Value
- Method ChoiceFieldFluent.Choice
- Method ChoiceFieldFluent.Choices
- Method ChoiceFieldFluent.ChoicesBy
- Method ChoiceFieldFluent.Default
- Method ChoiceFieldFluent.DependsOn
- Method ChoiceFieldFluent.Help
- Method ChoiceFieldFluent.Label
- Method ChoiceFieldFluent.Maximum
- Method ChoiceFieldFluent.Minimum
- Method ChoiceFieldFluent.ParameterName
- Method ChoiceFieldFluent.PreviewBy
- Method ChoiceFieldFluent.Remember
- Method ChoiceFieldFluent.Required
- Method ChoiceFieldFluent.ShowWhen
- Method ChoiceFieldFluent.Validate
- Method ChoiceFieldFluent.Value
- Method Form.MultiSelect
- Method Form.Select
- Method FormPage.MultiSelect
- Method FormPage.Select
Accepted by parameters 32
- Extension method ChoiceField.Choice
- Extension method ChoiceField.Choices
- Extension method ChoiceField.ChoicesBy
- Extension method ChoiceField.Default
- Extension method ChoiceField.DependsOn
- Extension method ChoiceField.Help
- Extension method ChoiceField.Label
- Extension method ChoiceField.Maximum
- Extension method ChoiceField.Minimum
- Extension method ChoiceField.ParameterName
- Extension method ChoiceField.PreviewBy
- Extension method ChoiceField.Remember
- Extension method ChoiceField.Required
- Extension method ChoiceField.ShowWhen
- Extension method ChoiceField.Validate
- Extension method ChoiceField.Value
- Method ChoiceFieldFluent.Choice
- Method ChoiceFieldFluent.Choices
- Method ChoiceFieldFluent.ChoicesBy
- Method ChoiceFieldFluent.Default
- Method ChoiceFieldFluent.DependsOn
- Method ChoiceFieldFluent.Help
- Method ChoiceFieldFluent.Label
- Method ChoiceFieldFluent.Maximum
- Method ChoiceFieldFluent.Minimum
- Method ChoiceFieldFluent.ParameterName
- Method ChoiceFieldFluent.PreviewBy
- Method ChoiceFieldFluent.Remember
- Method ChoiceFieldFluent.Required
- Method ChoiceFieldFluent.ShowWhen
- Method ChoiceFieldFluent.Validate
- Method ChoiceFieldFluent.Value
Constructors
public ChoiceField(string key, string? label = null, bool multiple = false) #Creates a choice field.
Parameters
- key string
- The key.
- label string? = null
- The label.
- multiple bool = false
- Whether several values can be chosen.
Methods
public override string Display(object? value, PromptLabels labels) #The value as shown in the form and on the review page.
Parameters
- value object?
- The value.
- labels ConsoleMonster.Interactive.PromptLabels
- The labels.
Returns
string The text.Inherited Methods
Properties
public IList<Choice> Choices { get; } #The choices (replaced by the loader's result when one is set).
public Func<FormValues, CancellationToken, Task<IEnumerable<Choice>>>? LoadChoices { get; set; } #Fluent("ChoicesBy")Loads the choices from the current values (dependent fields).
public Func<Choice, IWidget?>? Preview { get; set; } #Fluent("PreviewBy")Preview content for the focused choice in the editor.
Inherited Properties
Extension Methods
public static ChoiceField Choice(ChoiceField choiceField, Choice item) #Adds an item to ChoiceField.Choices: The choices (replaced by the loader's result when one is set).
Parameters
- choiceField ConsoleMonster.Interactive.ChoiceField
- The instance.
- item ConsoleMonster.Interactive.Choice
- The item.
public static ChoiceField Choices(ChoiceField choiceField, IEnumerable<Choice> items) #Adds items to ChoiceField.Choices: The choices (replaced by the loader's result when one is set).
Parameters
- choiceField ConsoleMonster.Interactive.ChoiceField
- The instance.
- items System.Collections.Generic.IEnumerable<ConsoleMonster.Interactive.Choice>
- The items, in order.
public static ChoiceField ChoicesBy(ChoiceField choiceField, Func<FormValues, CancellationToken, Task<IEnumerable<Choice>>>? value) #Sets ChoiceField.LoadChoices: Loads the choices from the current values (dependent fields).
Parameters
- choiceField ConsoleMonster.Interactive.ChoiceField
- The instance.
- value System.Func<ConsoleMonster.Interactive.FormValues, System.Threading.CancellationToken, System.Threading.Tasks.Task<System.Collections.Generic.IEnumerable<ConsoleMonster.Interactive.Choice>>>?
- The callback.
Examples
// C# initializer or property // C# fluent
choiceField.LoadChoices = value; choiceField.ChoicesBy(value);public static ChoiceField Default(ChoiceField choiceField, object? value) #Sets Field.Default: The declared default: the starting value until a value is set, and values equal to it are left out of the equivalent command.
Parameters
- choiceField ConsoleMonster.Interactive.ChoiceField
- The instance.
- value object?
- The value.
Examples
// C# initializer or property // C# fluent
choiceField.Default = value; choiceField.Default(value);public static ChoiceField DependsOn(ChoiceField choiceField, string item) #Adds an item to Field.DependsOn: Fields whose change resets this field (and reloads its options).
Parameters
- choiceField ConsoleMonster.Interactive.ChoiceField
- The instance.
- item string
- The item.
public static ChoiceField DependsOn(ChoiceField choiceField, IEnumerable<string> items) #Adds items to Field.DependsOn: Fields whose change resets this field (and reloads its options).
Parameters
- choiceField ConsoleMonster.Interactive.ChoiceField
- The instance.
- items System.Collections.Generic.IEnumerable<string>
- The items, in order.
public static ChoiceField Help(ChoiceField choiceField, string? value) #Sets Field.Help: Help shown while the field has focus.
Parameters
- choiceField ConsoleMonster.Interactive.ChoiceField
- The instance.
- value string?
- The value.
Examples
// C# initializer or property // C# fluent
choiceField.Help = value; choiceField.Help(value);public static ChoiceField Label(ChoiceField choiceField, string value) #Sets Field.Label: The label.
Parameters
- choiceField ConsoleMonster.Interactive.ChoiceField
- The instance.
- value string
- The value.
Examples
// C# initializer or property // C# fluent
choiceField.Label = value; choiceField.Label(value);public static ChoiceField Maximum(ChoiceField choiceField, int? value) #Sets ChoiceField.Maximum: The most values (multiple).
Parameters
- choiceField ConsoleMonster.Interactive.ChoiceField
- The instance.
- value int?
- The value.
Examples
// C# initializer or property // C# fluent
choiceField.Maximum = value; choiceField.Maximum(value);public static ChoiceField Minimum(ChoiceField choiceField, int? value) #Sets ChoiceField.Minimum: The fewest values (multiple).
Parameters
- choiceField ConsoleMonster.Interactive.ChoiceField
- The instance.
- value int?
- The value.
Examples
// C# initializer or property // C# fluent
choiceField.Minimum = value; choiceField.Minimum(value);public static ChoiceField ParameterName(ChoiceField choiceField, string? value) #Sets Field.ParameterName: The command-line parameter this field supplies (Domain, -Domain, --domain); null leaves the field out of the equivalent command.
Parameters
- choiceField ConsoleMonster.Interactive.ChoiceField
- The instance.
- value string?
- The value.
Examples
// C# initializer or property // C# fluent
choiceField.ParameterName = value; choiceField.ParameterName(value);public static ChoiceField PreviewBy(ChoiceField choiceField, Func<Choice, IWidget?>? value) #Sets ChoiceField.Preview: Preview content for the focused choice in the editor.
Parameters
- choiceField ConsoleMonster.Interactive.ChoiceField
- The instance.
- value System.Func<ConsoleMonster.Interactive.Choice, ConsoleMonster.Layout.IWidget?>?
- The callback.
Examples
// C# initializer or property // C# fluent
choiceField.Preview = value; choiceField.PreviewBy(value);public static ChoiceField Remember(ChoiceField choiceField, bool value = true) #Sets Field.Remember: Whether the value is kept in presets and remembered choices (never for secrets).
Parameters
- choiceField ConsoleMonster.Interactive.ChoiceField
- The instance.
- value bool = true
- The value; true when omitted.
Examples
// C# initializer or property // C# fluent
choiceField.Remember = value; choiceField.Remember(value);public static ChoiceField Required(ChoiceField choiceField, bool value = true) #Sets Field.Required: Whether an empty value is refused.
Parameters
- choiceField ConsoleMonster.Interactive.ChoiceField
- The instance.
- value bool = true
- The value; true when omitted.
Examples
// C# initializer or property // C# fluent
choiceField.Required = value; choiceField.Required(value);public static ChoiceField ShowWhen(ChoiceField choiceField, Func<FormValues, bool>? value) #Sets Field.VisibleWhen: Shows the field only while this returns true.
Parameters
- choiceField ConsoleMonster.Interactive.ChoiceField
- The instance.
- value System.Func<ConsoleMonster.Interactive.FormValues, bool>?
- The callback.
Examples
// C# initializer or property // C# fluent
choiceField.VisibleWhen = value; choiceField.ShowWhen(value);public static ChoiceField Validate(ChoiceField choiceField, Func<object?, FormValues, string?>? value) #Sets Field.Validator: A validator: returns an error message, or null when the value is fine.
Parameters
- choiceField ConsoleMonster.Interactive.ChoiceField
- The instance.
- value System.Func<object?, ConsoleMonster.Interactive.FormValues, string?>?
- The callback.
Examples
// C# initializer or property // C# fluent
choiceField.Validator = value; choiceField.Validate(value);public static ChoiceField Value(ChoiceField choiceField, object? value) #Sets Field.Value: The current value.
Parameters
- choiceField ConsoleMonster.Interactive.ChoiceField
- The instance.
- value object?
- The value.
Examples
// C# initializer or property // C# fluent
choiceField.Value = value; choiceField.Value(value);