UNPKG

1.14 kBTypeScriptView Raw
1import { StrictValidator } from "typanion";
2import { GeneralOptionFlags, CommandOptionReturn, WithArity } from "./utils";
3export type ArrayFlags<T, Arity extends number = 1> = GeneralOptionFlags & {
4 arity?: Arity;
5 validator?: StrictValidator<unknown, Array<T>>;
6};
7/**
8 * Used to annotate array options. Such options will be strings unless they
9 * are provided a schema, which will then be used for coercion.
10 *
11 * @example
12 * --foo hello --foo bar
13 * ► {"foo": ["hello", "world"]}
14 */
15export declare function Array<T extends {} = string, Arity extends number = 1>(descriptor: string, opts: ArrayFlags<T, Arity> & {
16 required: true;
17}): CommandOptionReturn<Array<WithArity<T, Arity>>>;
18export declare function Array<T extends {} = string, Arity extends number = 1>(descriptor: string, opts?: ArrayFlags<T, Arity>): CommandOptionReturn<Array<WithArity<T, Arity>> | undefined>;
19export declare function Array<T extends {} = string, Arity extends number = 1>(descriptor: string, initialValue: Array<WithArity<string, Arity>>, opts?: Omit<ArrayFlags<T, Arity>, 'required'>): CommandOptionReturn<Array<WithArity<T, Arity>>>;