Revert "Templates: replace validvalues with choice (BC) (#17653)"

This reverts commit 02cc6899a7.
This commit is contained in:
andig 2024-12-29 11:32:25 +01:00
parent 6db5b66f0e
commit a6bb2efe7e
29 changed files with 50 additions and 70 deletions

View file

@ -444,7 +444,7 @@ func (c *CmdConfigure) processInputConfig(param templates.Param) string {
exampleValue: param.Example,
help: param.Help.ShortString(c.lang),
valueType: param.Type,
choice: param.Choice,
validValues: param.ValidValues,
mask: param.IsMasked(),
required: param.IsRequired(),
})

View file

@ -104,7 +104,7 @@ type question struct {
label, help string
defaultValue, exampleValue string
invalidValues []string
choice []string
validValues []string
valueType templates.ParamType
minNumberValue, maxNumberValue int64
mask, required bool
@ -130,11 +130,11 @@ func (c *CmdConfigure) askParam(p templates.Param) string {
}
return c.askValue(question{
label: p.Description.String(c.lang),
valueType: p.Type,
choice: p.Choice,
mask: mask,
required: required,
label: p.Description.String(c.lang),
valueType: p.Type,
validValues: p.Choice, // TODO proper choice handling
mask: mask,
required: required,
})
}
@ -155,8 +155,8 @@ func (c *CmdConfigure) askValue(q question) string {
if q.valueType == templates.TypeChoice {
label := strings.TrimSpace(strings.Join([]string{q.label, c.localizedString("Value_Choice")}, " "))
idx, _ := c.askChoice(label, q.choice)
return q.choice[idx]
idx, _ := c.askChoice(label, q.validValues)
return q.validValues[idx]
}
if q.valueType == templates.TypeChargeModes {
@ -181,7 +181,7 @@ func (c *CmdConfigure) askValue(q question) string {
return errors.New(c.localizedString("ValueError_Used"))
}
if q.choice != nil && !slices.Contains(q.choice, value) {
if q.validValues != nil && !slices.Contains(q.validValues, value) {
return errors.New(c.localizedString("ValueError_Invalid"))
}