Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite4aef27

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

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
returnerr
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+
iferr!=nil {
113+
returnerr
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+
iferr!=nil {
123+
returnerr
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+
iferr!=nil {
133+
returnerr
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+
returnerr
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)

[8]ページ先頭

©2009-2025 Movatter.jp