diff --git a/README.md b/README.md index ccf816ff..3491610d 100644 --- a/README.md +++ b/README.md @@ -53,6 +53,7 @@ func main() { ``` ## Examples + Examples can be found in the `examples/` directory. Run them to see basic behavior: ```bash @@ -67,6 +68,7 @@ go run examples/validation.go ## Prompts ### Input + ```golang @@ -79,6 +81,7 @@ survey.AskOne(prompt, &name, nil) ### Password + ```golang @@ -91,6 +94,7 @@ survey.AskOne(prompt, &password, nil) ### Confirm + ```golang @@ -103,6 +107,7 @@ survey.AskOne(prompt, &name, nil) ### Select + ```golang @@ -116,6 +121,7 @@ survey.AskOne(prompt, &color, nil) ### MultiSelect + ```golang @@ -147,6 +153,7 @@ q := &survey.Question{ ``` ### Built-in Validators + `survey` comes prepackaged with a few validators to fit common situations. Currently these validators include: @@ -156,6 +163,58 @@ validators include: | MinLength(n) | string | Enforces that a response is at least the given length | | MaxLength(n) | string | Enforces that a response is no longer than the given length | +## Help Text + +All of the prompts (except `Password`) have a `Help` field which can be defined to provide more information to your users: + + +```golang +&survey.Input{ + Message: "What is your phone number:", + Help: "Phone number should include the area code", +} +``` + +### Changing the input rune + +In some situations, `?` is a perfectly valid response. To handle this, you can change the rune that survey +looks for by setting the `HideInputRune` variable in `survey/core`: + +```golang + +import ( + "gopkg.in/AlecAivazis/survey.v1" + surveyCore "gopkg.in/AlecAivazis/survey.v1/core" +) + +number := "" +prompt := &survey.Input{ + Message: "If you have this need, please give me a reasonable message.", + Help: "I couldn't come up with one.", +} + +surveyCore.HideInputRune = '^' + +survey.AskOne(prompt, &number, nil) +``` + + +## Customizing Output + +Customizing the icons and various parts of survey can easily be done by setting the following variables +in `survey/core`: + +| name | default | description | +|---------------------|----------------|-------------------------------------------------------------------| +| ErrorIcon | ✘ | Before an error | +| HelpIcon | ⓘ | Before help text | +| QuestionIcon | ? | Before the message of a prompt | +| SelectFocusIcon | ❯ | Marks the current selection in `Select` and `MultiSelect` prompts | +| MarkedOptionIcon | ◉ | Marks a chosen selection in a `MultiSelect` prompt | +| UnmarkedOptionIcon | ◯ | Marks an unselected option in a `MultiSelect` prompt | + + + ## Versioning This project tries to maintain semantic GitHub releases as closely as possible. As such, services