Skip to content

Commit

Permalink
add promptui git bash bug examples
Browse files Browse the repository at this point in the history
  • Loading branch information
Silthus committed Aug 4, 2022
0 parents commit 75a641f
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 0 deletions.
10 changes: 10 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -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
)
10 changes: 10 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -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=
53 changes: 53 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
@@ -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)
}

0 comments on commit 75a641f

Please sign in to comment.