diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..45d07a4 --- /dev/null +++ b/go.mod @@ -0,0 +1,10 @@ +module github.com/silthus/promptui-git-bash-bug + +go 1.19 + +require github.com/manifoldco/promptui v0.9.0 + +require ( + github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e // indirect + golang.org/x/sys v0.0.0-20181122145206-62eef0e2fa9b // indirect +) diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..34fdb2a --- /dev/null +++ b/go.sum @@ -0,0 +1,10 @@ +github.com/chzyer/logex v1.1.10 h1:Swpa1K6QvQznwJRcfTfQJmTE72DqScAa40E+fbHEXEE= +github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= +github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e h1:fY5BOSpyZCqRo5OhCuC+XN+r/bBCmeuuJtjz+bCNIf8= +github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= +github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1 h1:q763qf9huN11kDQavWsoZXJNW3xEE4JJyHa5Q25/sd8= +github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= +github.com/manifoldco/promptui v0.9.0 h1:3V4HzJk1TtXW1MTZMP7mdlwbBpIinw3HztaIlYthEiA= +github.com/manifoldco/promptui v0.9.0/go.mod h1:ka04sppxSGFAtxX0qhlYQjISsg9mR4GWtQEhdbn6Pgg= +golang.org/x/sys v0.0.0-20181122145206-62eef0e2fa9b h1:MQE+LT/ABUuuvEZ+YQAMSXindAdUh7slEmAkup74op4= +golang.org/x/sys v0.0.0-20181122145206-62eef0e2fa9b/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= diff --git a/main.go b/main.go new file mode 100644 index 0000000..78d796f --- /dev/null +++ b/main.go @@ -0,0 +1,53 @@ +package main + +import ( + "fmt" + "github.com/manifoldco/promptui" + "os" +) + +func main() { + args := os.Args + if len(args) < 2 { + fmt.Println("Please run with one of the types: select, prompt, confirm") + return + } + + switch args[1] { + case "select": + runSelect() + case "prompt": + runPrompt() + case "confirm": + runConfirm() + } +} + +func runSelect() { + s := &promptui.Select{ + Items: []string{"One", "Two", "Three"}, + } + i, result, err := s.Run() + fmt.Println("Error:", err) + fmt.Println("Result:", result) + fmt.Println("Index:", i) +} + +func runPrompt() { + p := &promptui.Prompt{ + Label: "Prompt", + } + result, err := p.Run() + fmt.Println("Error:", err) + fmt.Println("Result:", result) +} + +func runConfirm() { + p := &promptui.Prompt{ + Label: "Confirm", + IsConfirm: true, + } + result, err := p.Run() + fmt.Println("Error:", err) + fmt.Println("Result:", result) +}