Simple CLI questions and answers
go get github.com/matt9mg/go-cli-questions
q := questions.NewQuestion()
answer, err := q.Ask("hi there")
if err != nil {
log.Fatalln(err)
}
log.Println(answer)
// asks a question but the terminal does not display the input
pw, err := q.AskSecurely("password")
if err != nil {
log.Fatalln(err)
}
log.Println(pw)
Custom Template Handler
type CustomTemplate struct {}
func (*CustomTemplate) Write(data []byte) error {
t, err := template.ParseGlob("/*.tmpl")
if err != nil {
return err
}
return t.ExecuteTemplate(os.Stdout, "hello.tmpl", data)
}
func main() {
q := questions.NewQuestion(
questions.WithCustomTemplate(&CustomTemplate{}),
)
a, err := q.Ask("hi there")
if err != nil {
log.Fatalln(err)
}
log.Println(a)
}
This project is licensed under the MIT License - see the LICENSE.md file for details
We take no legal responsibility for anything this code is used for.