Skip to content

Commit e4aef27

Browse files
authored
chore: add example prompt command for multiple prompt bug (#13885)
Prompt message is not erased after the prompt ends
1 parent c6b7588 commit e4aef27

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

cli/prompts.go

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,45 @@ func (RootCmd) promptExample() *serpent.Command {
100100
}
101101
return err
102102
}, useSearchOption),
103+
promptCmd("multiple", func(inv *serpent.Invocation) error {
104+
_, _ = fmt.Fprintf(inv.Stdout, "This command exists to test the behavior of multiple prompts. The survey library does not erase the original message prompt after.")
105+
thing, err := cliui.Select(inv, cliui.SelectOptions{
106+
Message: "Select a thing",
107+
Options: []string{
108+
"Car", "Bike", "Plane", "Boat", "Train",
109+
},
110+
Default: "Car",
111+
})
112+
if err != nil {
113+
return err
114+
}
115+
color, err := cliui.Select(inv, cliui.SelectOptions{
116+
Message: "Select a color",
117+
Options: []string{
118+
"Blue", "Green", "Yellow", "Red",
119+
},
120+
Default: "Blue",
121+
})
122+
if err != nil {
123+
return err
124+
}
125+
properties, err := cliui.MultiSelect(inv, cliui.MultiSelectOptions{
126+
Message: "Select properties",
127+
Options: []string{
128+
"Fast", "Cool", "Expensive", "New",
129+
},
130+
Defaults: []string{"Fast"},
131+
})
132+
if err != nil {
133+
return err
134+
}
135+
_, _ = fmt.Fprintf(inv.Stdout, "Your %s %s is awesome! Did you paint it %s?\n",
136+
strings.Join(properties, " "),
137+
thing,
138+
color,
139+
)
140+
return err
141+
}),
103142
promptCmd("multi-select", func(inv *serpent.Invocation) error {
104143
values, err := cliui.MultiSelect(inv, cliui.MultiSelectOptions{
105144
Message: "Select some things:",

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy