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

Commit

Permalink
Fix default input display (#314)
Browse files Browse the repository at this point in the history
* fixed bug prevent default answer from being displayed in Input - fixes #310

* added comments
  • Loading branch information
AlecAivazis committed Nov 18, 2020
1 parent 60b57e7 commit 288b412
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion input.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,13 +190,20 @@ 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: i.answer,
Answer: ans,
},
)
}

0 comments on commit 288b412

Please sign in to comment.