fix(choose): error if selected options > limit

Rationale: If the number of selected options in `--selected` flag is
greater than the limit, the last `n` options are selected where `n` is
the limit.
This commit is contained in:
Dhruv Manilawala 2022-10-08 10:13:55 +05:30 committed by Maas Lalani
parent 1353b97272
commit 2c66222fd8

View file

@ -46,6 +46,10 @@ func (o Options) Run() error {
o.Limit = len(o.Options)
}
if len(o.Selected) > o.Limit {
return errors.New("number of selected options cannot be greater than the limit")
}
// Keep track of the selected items.
currentSelected := 0
// Check if selected items should be used.