Text prompts the user for a text value
(varName string)
| 30 | |
| 31 | // Text prompts the user for a text value |
| 32 | func (p *Prompter) Text(varName string) (string, error) { |
| 33 | m := newTextModel(varName) |
| 34 | |
| 35 | prog := tea.NewProgram(m, |
| 36 | tea.WithInput(p.Stdin), |
| 37 | tea.WithOutput(p.Stderr), |
| 38 | ) |
| 39 | |
| 40 | result, err := prog.Run() |
| 41 | if err != nil { |
| 42 | return "", err |
| 43 | } |
| 44 | |
| 45 | model := result.(textModel) |
| 46 | if model.cancelled { |
| 47 | return "", ErrCancelled |
| 48 | } |
| 49 | |
| 50 | return model.value, nil |
| 51 | } |
| 52 | |
| 53 | // Select prompts the user to select from a list of options |
| 54 | func (p *Prompter) Select(varName string, options []string) (string, error) { |
no test coverage detected