1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 | export class ArgumentParser extends ArgumentGroup {
|
13 | constructor(options?: ArgumentParserOptions);
|
14 | add_subparsers(options?: SubparserOptions): SubParser;
|
15 | parse_args(args?: string[], ns?: Namespace | object): any;
|
16 | print_usage(): void;
|
17 | print_help(): void;
|
18 | format_usage(): string;
|
19 | format_help(): string;
|
20 | parse_known_args(args?: string[], ns?: Namespace | object): any[];
|
21 | convert_arg_line_to_args(argLine: string): string[];
|
22 | exit(status: number, message: string): void;
|
23 | error(err: string | Error): void;
|
24 | }
|
25 |
|
26 | // tslint:disable-next-line:no-unnecessary-class
|
27 | export class Namespace {
|
28 | constructor(options: object);
|
29 | [key: string]: any;
|
30 | }
|
31 |
|
32 | export class SubParser {
|
33 | add_parser(name: string, options?: SubArgumentParserOptions): ArgumentParser;
|
34 | }
|
35 |
|
36 | export class ArgumentGroup {
|
37 | add_argument(arg: string, options?: ArgumentOptions): void;
|
38 | add_argument(arg1: string, arg2: string, options?: ArgumentOptions): void;
|
39 | add_argument_group(options?: ArgumentGroupOptions): ArgumentGroup;
|
40 | add_mutually_exclusive_group(options?: { required: boolean }): ArgumentGroup;
|
41 | set_defaults(options?: {}): void;
|
42 | get_default(dest: string): any;
|
43 | }
|
44 |
|
45 | export interface SubparserOptions {
|
46 | title?: string | undefined;
|
47 | description?: string | undefined;
|
48 | prog?: string | undefined;
|
49 | parser_class?: { new (): any } | undefined;
|
50 | action?: string | undefined;
|
51 | dest?: string | undefined;
|
52 | help?: string | undefined;
|
53 | metavar?: string | undefined;
|
54 | required?: boolean | undefined;
|
55 | }
|
56 |
|
57 | export interface SubArgumentParserOptions extends ArgumentParserOptions {
|
58 | aliases?: string[] | undefined;
|
59 | help?: string | undefined;
|
60 | }
|
61 |
|
62 | export interface ArgumentParserOptions {
|
63 | description?: string | undefined;
|
64 | epilog?: string | undefined;
|
65 | add_help?: boolean | undefined;
|
66 | argument_default?: any;
|
67 | parents?: ArgumentParser[] | undefined;
|
68 | prefix_chars?: string | undefined;
|
69 | formatter_class?: {
|
70 | new (): HelpFormatter | ArgumentDefaultsHelpFormatter | RawDescriptionHelpFormatter | RawTextHelpFormatter;
|
71 | } | undefined;
|
72 | prog?: string | undefined;
|
73 | usage?: string | undefined;
|
74 | exit_on_error?: boolean | undefined;
|
75 | }
|
76 |
|
77 | export interface ArgumentGroupOptions {
|
78 | prefix_chars?: string | undefined;
|
79 | argument_default?: any;
|
80 | title?: string | undefined;
|
81 | description?: string | undefined;
|
82 | }
|
83 |
|
84 | export abstract class Action {
|
85 | protected dest: string;
|
86 | constructor(options: ActionConstructorOptions);
|
87 | abstract call(
|
88 | parser: ArgumentParser,
|
89 | namespace: Namespace,
|
90 | values: string | string[],
|
91 | optionString: string | null,
|
92 | ): void;
|
93 | }
|
94 |
|
95 | // Can be used in conjunction with the exit_on_error flag to save the error message
|
96 | // and use it in a fashion other than printing to stdout.
|
97 | export class ArgumentError extends Error {
|
98 | constructor(argument: Action, message: string);
|
99 | str(): string;
|
100 | }
|
101 |
|
102 | // An error from trying to convert a command line string to a type.
|
103 | export class ArgumentTypeError extends Error {
|
104 | constructor(message: string);
|
105 | }
|
106 |
|
107 | // Passed to the Action constructor. Subclasses are just expected to relay this to
|
108 | // the super() constructor, so using an "opaque type" pattern is probably fine.
|
109 | // Someone may want to fill this out in the future.
|
110 | export type ActionConstructorOptions = number & { _: "ActionConstructorOptions" };
|
111 |
|
112 | export class HelpFormatter {}
|
113 | export class ArgumentDefaultsHelpFormatter {}
|
114 | export class RawDescriptionHelpFormatter {}
|
115 | export class RawTextHelpFormatter {}
|
116 |
|
117 | export interface ArgumentOptions {
|
118 | action?: string | { new (options: ActionConstructorOptions): Action } | undefined;
|
119 | option_strings?: string[] | undefined;
|
120 | dest?: string | undefined;
|
121 | nargs?: string | number | undefined;
|
122 | const?: any;
|
123 | default?: any;
|
124 |
|
125 | type?: string | Function | undefined;
|
126 | choices?: string | string[] | undefined;
|
127 | required?: boolean | undefined;
|
128 | help?: string | undefined;
|
129 | metavar?: string | string[] | undefined;
|
130 | version?: string | undefined;
|
131 | }
|
132 |
|
133 | export class BooleanOptionalAction extends Action {
|
134 | call(parser: ArgumentParser, namespace: Namespace, values: string | string[], optionString: string | null): void;
|
135 | }
|
136 |
|
137 | export const SUPPRESS: string;
|
138 | export const OPTIONAL: string;
|
139 | export const ZERO_OR_MORE: string;
|
140 | export const ONE_OR_MORE: string;
|
141 | export const REMAINDER: string;
|
142 | export const PARSER: string;
|