1 | import { StrictValidator } from 'typanion';
|
2 | import { CommandBuilder, RunState } from '../../core';
|
3 | import { UsageError } from '../../errors';
|
4 | import { BaseContext, CliContext } from '../Cli';
|
5 | export declare const isOptionSymbol: unique symbol;
|
6 | export type GeneralOptionFlags = {
|
7 | description?: string;
|
8 | hidden?: boolean;
|
9 | required?: boolean;
|
10 | };
|
11 | export type TupleOf<Type, Arity extends number, Accumulator extends Array<Type>> = Accumulator['length'] extends Arity ? Accumulator : TupleOf<Type, Arity, [Type, ...Accumulator]>;
|
12 | export type Tuple<Type, Arity extends number> = Arity extends Arity ? number extends Arity ? Array<Type> : TupleOf<Type, Arity, []> : never;
|
13 | export type WithArity<Type extends {
|
14 | length?: number;
|
15 | }, Arity extends number> = number extends Type['length'] ? Arity extends 0 ? boolean : Arity extends 1 ? Type : number extends Arity ? boolean | Type | Tuple<Type, Arity> : Tuple<Type, Arity> : Type;
|
16 | export type CommandOption<T> = {
|
17 | [isOptionSymbol]: true;
|
18 | definition: <Context extends BaseContext>(builder: CommandBuilder<CliContext<Context>>, key: string) => void;
|
19 | transformer: <Context extends BaseContext>(builder: CommandBuilder<CliContext<Context>>, key: string, state: RunState, context: Context) => T;
|
20 | };
|
21 | export type CommandOptionReturn<T> = T;
|
22 | export declare function makeCommandOption<T>(spec: Omit<CommandOption<T>, typeof isOptionSymbol>): T;
|
23 | export declare function rerouteArguments<A, B>(a: A | B, b: B): [Exclude<A, B>, B];
|
24 | export declare function rerouteArguments<A, B>(a: A | B | undefined, b: B): [Exclude<A, B> | undefined, B];
|
25 | export declare function cleanValidationError(message: string, { mergeName }?: {
|
26 | mergeName?: boolean;
|
27 | }): string;
|
28 | export declare function formatError(message: string, errors: Array<string>): UsageError;
|
29 | export declare function applyValidator<U, V>(name: string, value: U, validator?: StrictValidator<unknown, V>): U;
|