Skip to content
This repository has been archived by the owner on Apr 19, 2024. It is now read-only.

Commit

Permalink
Merge pull request #49 from AlecAivazis/feat/help-docs
Browse files Browse the repository at this point in the history
Feat/help docs
  • Loading branch information
AlecAivazis authored Apr 27, 2017
2 parents aec05d7 + a7497d9 commit f3348d3
Showing 1 changed file with 59 additions and 0 deletions.
59 changes: 59 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ func main() {
```

## Examples

Examples can be found in the `examples/` directory. Run them
to see basic behavior:
```bash
Expand All @@ -67,6 +68,7 @@ go run examples/validation.go
## Prompts

### Input

<img src="https://media.giphy.com/media/3og0IxS8JsuD9Z8syA/giphy.gif" width="400px"/>

```golang
Expand All @@ -79,6 +81,7 @@ survey.AskOne(prompt, &name, nil)


### Password

<img src="https://media.giphy.com/media/26FmQr6mUivkq71GE/giphy.gif" width="400px" />

```golang
Expand All @@ -91,6 +94,7 @@ survey.AskOne(prompt, &password, nil)


### Confirm

<img src="https://media.giphy.com/media/3oKIPgsUmTp4m3eo4E/giphy.gif" width="400px"/>

```golang
Expand All @@ -103,6 +107,7 @@ survey.AskOne(prompt, &name, nil)


### Select

<img src="https://media.giphy.com/media/3oKIPxigmMu5YqpUPK/giphy.gif" width="400px"/>

```golang
Expand All @@ -116,6 +121,7 @@ survey.AskOne(prompt, &color, nil)


### MultiSelect

<img src="https://media.giphy.com/media/3oKIP8lHYFtGeQDH0c/giphy.gif" width="400px"/>

```golang
Expand Down Expand Up @@ -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:

Expand All @@ -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:
<img src="https://media.giphy.com/media/l1KVbc5CehW6r7pss/giphy.gif" width="400px" style="margin-top: 8px"/>

```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
Expand Down

0 comments on commit f3348d3

Please sign in to comment.