Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions cmd/jen/internal/spec/spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,13 @@ func loadConfirmStep(_map yaml.Map) (exec.Executable, error) {
if err != nil {
return nil, err
}
defaultValue, err := getOptionalBool(_map, "default", false)
if err != nil {
return nil, err
}
return steps.Confirm{
Message: message,
Default: defaultValue,
Then: executables,
}, nil
}
Expand Down
20 changes: 20 additions & 0 deletions cmd/jen/internal/spec/spec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,26 @@ then:
},
},
},
{
Name: "confirm with default true",
Buffer: `
confirm: Message
default: true
then:
- input:
question: Message
var: Variable`,
Expected: steps.Confirm{
Message: "Message",
Default: true,
Then: exec.Executables{
input.Prompt{
Message: "Message",
Var: "Variable",
},
},
},
},
{
Name: "set step",
Buffer: `
Expand Down
3 changes: 2 additions & 1 deletion cmd/jen/internal/steps/confirm.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
// user answers Yes when prompted for given message
type Confirm struct {
Message string
Default bool
Then exec.Executables
}

Expand All @@ -26,7 +27,7 @@ func (c Confirm) Execute(context exec.Context) error {
}
prompt := &survey.Confirm{
Message: message,
Default: false,
Default: c.Default,
}
value := false
if err := survey.AskOne(prompt, &value); err != nil {
Expand Down
Loading