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

Commit

Permalink
Show transformed answer after submitting input (#450)
Browse files Browse the repository at this point in the history
Co-authored-by: Mislav Marohnić <git@mislav.net>
  • Loading branch information
twelvelabs and mislav committed Sep 21, 2022
1 parent bf4b865 commit a98a037
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 8 deletions.
9 changes: 1 addition & 8 deletions input.go
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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

0 comments on commit a98a037

Please sign in to comment.