Skip to content

Commit

Permalink
Allow choices text to default to value
Browse files Browse the repository at this point in the history
Signed-off-by: Mathieu Frenette <[email protected]>
  • Loading branch information
silphid committed Mar 26, 2021
1 parent 22f3a27 commit a68f789
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/internal/spec/spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -338,11 +338,11 @@ func loadChoiceStep(_map yaml.Map) (exec.Executable, error) {
if !ok {
return nil, fmt.Errorf("items of %q property must be objects", "options")
}
text, err := getRequiredStringFromMap(childMap, "text")
value, err := getRequiredStringFromMap(childMap, "value")
if err != nil {
return nil, err
}
value, err := getRequiredStringFromMap(childMap, "value")
text, err := getOptionalStringFromMap(childMap, "text", value)
if err != nil {
return nil, err
}
Expand Down
5 changes: 2 additions & 3 deletions src/internal/spec/spec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,7 @@ choice:
value: Value 1
- text: Text 2
value: Value 2
- text: Text 3
value: Value 3`,
- value: Value 3`,
Expected: choice.Prompt{
Message: "Message",
Var: "Variable",
Expand All @@ -215,7 +214,7 @@ choice:
Value: "Value 2",
},
{
Text: "Text 3",
Text: "Value 3",
Value: "Value 3",
},
},
Expand Down

0 comments on commit a68f789

Please sign in to comment.