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

Show transformed answer after submitting input #450

Merged
merged 2 commits into from Sep 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 1 addition & 8 deletions input.go
Expand Up @@ -207,20 +207,13 @@ func (i *Input) Prompt(config *PromptConfig) (interface{}, error) {
}

func (i *Input) Cleanup(config *PromptConfig, val interface{}) error {
// use the default answer when cleaning up the prompt if necessary
ans := i.answer
if ans == "" && i.Default != "" {
ans = i.Default
}

// render the cleanup
return i.Render(
InputQuestionTemplate,
InputTemplateData{
Input: *i,
ShowAnswer: true,
Config: config,
Answer: ans,
Answer: val.(string),
},
)
}
1 change: 1 addition & 0 deletions survey_test.go
Expand Up @@ -380,6 +380,7 @@ func TestAsk(t *testing.T) {
func(c expectConsole) {
c.ExpectString("What is your name?")
c.SendLine("Johnny Appleseed")
c.ExpectString("What is your name? johnny appleseed")
c.ExpectEOF()
},
map[string]interface{}{
Expand Down