https://github.com/aisk/wizard
https://github.com/aisk/wizard
Last synced: about 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/aisk/wizard
- Owner: aisk
- Created: 2016-04-28T08:46:30.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2017-09-04T05:53:13.000Z (over 8 years ago)
- Last Synced: 2025-01-28T12:22:58.984Z (over 1 year ago)
- Language: Go
- Size: 5.86 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# wizard
Command line wizard helper in go.
## Install
```sh
go get -u github.com/aisk/wizard
```
## Example
```go
package main
import (
"fmt"
"github.com/aisk/wizard"
)
func main() {
username := ""
password := ""
loginNextTime := false
questions := []wizard.Question{
{
Content: "PLease input your user name:",
Input: &wizard.Input{
Result: &username,
},
},
{
Content: "Please input your password:",
Input: &wizard.Input{
Result: &password,
Hidden: true,
},
},
{
Content: "Login next time?",
Answers: []wizard.Answer{
{
Content: "yes",
Handler: func() {
loginNextTime = true
},
},
{
Content: "no",
Handler: func() {
loginNextTime = false
},
},
},
},
}
wizard.Ask(questions)
fmt.Println("Your username is", username)
fmt.Println("Your password is", password)
fmt.Println("Login next time is", loginNextTime)
}
```