Skip to content
This repository was archived by the owner on Apr 19, 2024. It is now read-only.

Commit a98a037

Browse files
twelvelabsmislav
andauthored
Show transformed answer after submitting input (#450)
Co-authored-by: Mislav Marohnić <git@mislav.net>
1 parent bf4b865 commit a98a037

File tree

2 files changed

+2
-8
lines changed

2 files changed

+2
-8
lines changed

input.go

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -207,20 +207,13 @@ func (i *Input) Prompt(config *PromptConfig) (interface{}, error) {
207207
}
208208

209209
func (i *Input) Cleanup(config *PromptConfig, val interface{}) error {
210-
// use the default answer when cleaning up the prompt if necessary
211-
ans := i.answer
212-
if ans == "" && i.Default != "" {
213-
ans = i.Default
214-
}
215-
216-
// render the cleanup
217210
return i.Render(
218211
InputQuestionTemplate,
219212
InputTemplateData{
220213
Input: *i,
221214
ShowAnswer: true,
222215
Config: config,
223-
Answer: ans,
216+
Answer: val.(string),
224217
},
225218
)
226219
}

survey_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,7 @@ func TestAsk(t *testing.T) {
380380
func(c expectConsole) {
381381
c.ExpectString("What is your name?")
382382
c.SendLine("Johnny Appleseed")
383+
c.ExpectString("What is your name? johnny appleseed")
383384
c.ExpectEOF()
384385
},
385386
map[string]interface{}{

0 commit comments

Comments
 (0)