MCPcopy Create free account
hub / github.com/bare-cli/bare / PromptString

Function PromptString

utils/ui/prompt.go:40–57  ·  view source on GitHub ↗
(label string, defval []string)

Source from the content-addressed store, hash-verified

38}
39
40func PromptString(label string, defval []string) string {
41 phDef := defval[0]
42 phDes := ""
43 if len(defval) > 1 {
44 phDes = defval[1]
45 }
46 fmt.Print(styles.StatusPrompt.Render("? "), label, " ", styles.Description.Render(phDes), styles.PromptStyle.Render(" ["+phDef+"]"), ": ")
47 input := bufio.NewReader(os.Stdin)
48 line, err := input.ReadString('\n')
49 if err != nil {
50 log.Fatal(err)
51 }
52 line = strings.TrimSuffix(line, "\n")
53 if len(line) == 0 {
54 return phDef
55 }
56 return line
57}
58
59func VarPromptSelect(label string, items []string) string {
60

Callers 2

AddLicenseFunction · 0.92
useBareFunction · 0.92

Calls

no outgoing calls

Tested by

no test coverage detected