| 2036 | ) { |
| 2037 | const results: Array<A> = [] |
| 2038 | const names = [single.name, ...single.aliases] |
| 2039 | const values = names.flatMap((name) => args.flags[name] ?? []) |
| 2040 | const count = values.length |
| 2041 | |
| 2042 | // Validate count constraints |
| 2043 | if (Predicate.isNotUndefined(options?.min) && count < options.min) { |
| 2044 | return yield* count === 0 |
| 2045 | ? new CliError.MissingOption({ option: single.name }) |
| 2046 | : new CliError.InvalidValue({ |
| 2047 | option: single.name, |
| 2048 | value: `${count} occurrences`, |
| 2049 | expected: `at least ${options.min} value${options.min === 1 ? "" : "s"}`, |
| 2050 | kind: single.kind |
| 2051 | }) |
| 2052 | } |
| 2053 | |
| 2054 | if (Predicate.isNotUndefined(options?.max) && count > options.max) { |
| 2055 | return yield* new CliError.InvalidValue({ |
| 2056 | option: single.name, |