Skip to content

Commit a68f789

Browse files
committed
Allow choices text to default to value
Signed-off-by: Mathieu Frenette <silphid@users.noreply.github.com>
1 parent 22f3a27 commit a68f789

2 files changed

Lines changed: 4 additions & 5 deletions

File tree

src/internal/spec/spec.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -338,11 +338,11 @@ func loadChoiceStep(_map yaml.Map) (exec.Executable, error) {
338338
if !ok {
339339
return nil, fmt.Errorf("items of %q property must be objects", "options")
340340
}
341-
text, err := getRequiredStringFromMap(childMap, "text")
341+
value, err := getRequiredStringFromMap(childMap, "value")
342342
if err != nil {
343343
return nil, err
344344
}
345-
value, err := getRequiredStringFromMap(childMap, "value")
345+
text, err := getOptionalStringFromMap(childMap, "text", value)
346346
if err != nil {
347347
return nil, err
348348
}

src/internal/spec/spec_test.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,7 @@ choice:
199199
value: Value 1
200200
- text: Text 2
201201
value: Value 2
202-
- text: Text 3
203-
value: Value 3`,
202+
- value: Value 3`,
204203
Expected: choice.Prompt{
205204
Message: "Message",
206205
Var: "Variable",
@@ -215,7 +214,7 @@ choice:
215214
Value: "Value 2",
216215
},
217216
{
218-
Text: "Text 3",
217+
Text: "Value 3",
219218
Value: "Value 3",
220219
},
221220
},

0 commit comments

Comments
 (0)