Read-SpectreText
Description
This function uses Spectre Console to prompt the user with a question and returns the user’s input.
Examples
Example 1
This example demonstrates a simple text prompt with a default answer.
Example 2
This example demonstrates a simple text prompt with a default answer and a color.
Example 3
This example demonstrates a simple text prompt with a default answer, a color, and a list of choices.
Parameters
Message
The question to prompt the user with.
Type | Required | Position | PipelineInput | Aliases |
---|---|---|---|---|
[String] | true | 1 | false | Title Question Prompt |
DefaultAnswer
The default answer if the user does not provide any input.
Type | Required | Position | PipelineInput |
---|---|---|---|
[String] | false | 2 | false |
AnswerColor
The color of the user’s answer input. The default behaviour uses the standard terminal text color.
Type | Required | Position | PipelineInput |
---|---|---|---|
[Color] | false | 3 | false |
AllowEmpty
If specified, the user can provide an empty answer.
Type | Required | Position | PipelineInput |
---|---|---|---|
[Switch] | false | named | false |
TimeoutSeconds
Type | Required | Position | PipelineInput |
---|---|---|---|
[Int32] | false | 4 | false |
Choices
An array of choices that the user can choose from. If specified, the user will be prompted with a list of choices to choose from, with validation. With autocomplete and can tab through the choices.
Type | Required | Position | PipelineInput |
---|---|---|---|
[String[]] | false | 5 | false |