UNPKG

1.53 kBTypeScriptView Raw
1import { Arg } from './args';
2import * as Flags from './flags';
3import { Metadata } from './metadata';
4export declare type OutputArgs = {
5 [name: string]: any;
6};
7export declare type OutputFlags<T extends ParserInput['flags']> = {
8 [P in keyof T]: any;
9};
10export declare type ParserOutput<TFlags extends OutputFlags<any>, TArgs extends OutputArgs> = {
11 flags: TFlags;
12 args: TArgs;
13 argv: string[];
14 raw: ParsingToken[];
15 metadata: Metadata;
16};
17export declare type ArgToken = {
18 type: 'arg';
19 input: string;
20};
21export declare type FlagToken = {
22 type: 'flag';
23 flag: string;
24 input: string;
25};
26export declare type ParsingToken = ArgToken | FlagToken;
27export interface ParserInput {
28 argv: string[];
29 flags: Flags.Input<any>;
30 args: Arg<any>[];
31 strict: boolean;
32 context: any;
33 '--'?: boolean;
34}
35export declare class Parser<T extends ParserInput, TFlags extends OutputFlags<T['flags']>, TArgs extends OutputArgs> {
36 private readonly input;
37 private readonly argv;
38 private readonly raw;
39 private readonly booleanFlags;
40 private readonly context;
41 private readonly metaData;
42 private currentFlag?;
43 constructor(input: T);
44 parse(): {
45 args: TArgs;
46 argv: any[];
47 flags: TFlags;
48 raw: ParsingToken[];
49 metadata: any;
50 };
51 private _args;
52 private _flags;
53 private _argv;
54 private _debugOutput;
55 private _debugInput;
56 private get _argTokens();
57 private get _flagTokens();
58 private _setNames;
59}