This repository has been archived by the owner on Apr 19, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 358
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #37 from AlecAivazis/fix/select-default-value
Fixed bug with multiple selects in the same readline instance
- Loading branch information
Showing
3 changed files
with
58 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/alecaivazis/survey" | ||
) | ||
|
||
var simpleQs = []*survey.Question{ | ||
{ | ||
Name: "color", | ||
Prompt: &survey.Select{ | ||
Message: "select1:", | ||
Options: []string{"red", "blue", "green"}, | ||
}, | ||
Validate: survey.Required, | ||
}, | ||
{ | ||
Name: "color2", | ||
Prompt: &survey.Select{ | ||
Message: "select2:", | ||
Options: []string{"red", "blue", "green"}, | ||
}, | ||
Validate: survey.Required, | ||
}, | ||
} | ||
|
||
func main() { | ||
answers := struct { | ||
Color string | ||
Color2 string | ||
}{} | ||
// ask the question | ||
err := survey.Ask(simpleQs, &answers) | ||
|
||
if err != nil { | ||
fmt.Println(err.Error()) | ||
return | ||
} | ||
// print the answers | ||
fmt.Printf("%s and %s.\n", answers.Color, answers.Color2) | ||
} |