|
| 1 | +// flow-typed signature: cab38813101e0a162deaae556391abc8 |
| 2 | +// flow-typed version: f7c859e705/yargs_v17.x.x/flow_>=v0.104.x |
| 3 | + |
| 4 | +declare module "yargs" { |
| 5 | + declare type Argv = { |
| 6 | + [key: string]: any, |
| 7 | + _: Array<string>, |
| 8 | + $0: string, |
| 9 | + ... |
| 10 | + }; |
| 11 | + |
| 12 | + declare type Options = $Shape<{ |
| 13 | + alias: string | Array<string>, |
| 14 | + array: boolean, |
| 15 | + boolean: boolean, |
| 16 | + choices: Array<mixed>, |
| 17 | + coerce: (arg: {[key: string]: any, ...} | any) => mixed, |
| 18 | + config: boolean, |
| 19 | + configParser: (configPath: string) => { [key: string]: mixed, ... }, |
| 20 | + conflicts: string | Array<string> | { [key: string]: string, ... }, |
| 21 | + count: boolean, |
| 22 | + default: mixed, |
| 23 | + defaultDescription: string, |
| 24 | + demandOption: boolean | string, |
| 25 | + desc: string, |
| 26 | + describe: string, |
| 27 | + description: string, |
| 28 | + global: boolean, |
| 29 | + group: string, |
| 30 | + hidden: boolean, |
| 31 | + implies: string | { [key: string]: string, ... }, |
| 32 | + nargs: number, |
| 33 | + normalize: boolean, |
| 34 | + number: boolean, |
| 35 | + required: boolean, |
| 36 | + requiresArg: boolean, |
| 37 | + skipValidation: boolean, |
| 38 | + string: boolean, |
| 39 | + type: "array" | "boolean" | "count" | "number" | "string", |
| 40 | + ... |
| 41 | + }>; |
| 42 | + |
| 43 | + declare type CommonModuleObject = {| |
| 44 | + command?: string | Array<string>, |
| 45 | + aliases?: Array<string> | string, |
| 46 | + builder?: { [key: string]: Options, ... } | ((yargsInstance: Yargs) => mixed), |
| 47 | + handler?: ((argv: Argv) => void) | ((argv: Argv) => Promise<void>) |
| 48 | + |}; |
| 49 | + |
| 50 | + declare type ModuleObjectDesc = {| |
| 51 | + ...CommonModuleObject, |
| 52 | + desc?: string | false |
| 53 | + |}; |
| 54 | + |
| 55 | + declare type ModuleObjectDescribe = {| |
| 56 | + ...CommonModuleObject, |
| 57 | + describe?: string | false |
| 58 | + |}; |
| 59 | + |
| 60 | + declare type ModuleObjectDescription = {| |
| 61 | + ...CommonModuleObject, |
| 62 | + description?: string | false |
| 63 | + |}; |
| 64 | + |
| 65 | + declare type ModuleObject = |
| 66 | + | ModuleObjectDesc |
| 67 | + | ModuleObjectDescribe |
| 68 | + | ModuleObjectDescription; |
| 69 | + |
| 70 | + declare type MiddleWareCallback = |
| 71 | + | (argv: Argv, yargsInstance?: Yargs) => void |
| 72 | + | (argv: Argv, yargsInstance?: Yargs) => Promise<void>; |
| 73 | + |
| 74 | + declare type Middleware = MiddleWareCallback | Array<MiddleWareCallback>; |
| 75 | + |
| 76 | + declare class Yargs { |
| 77 | + (args: Array<string>): Yargs; |
| 78 | + |
| 79 | + alias(key: string, alias: string): this; |
| 80 | + alias(alias: { [key: string]: string | Array<string>, ... }): this; |
| 81 | + argv: Argv | Promise<Argv>; |
| 82 | + array(key: string | Array<string>): this; |
| 83 | + boolean(parameter: string | Array<string>): this; |
| 84 | + check(fn: (argv: Argv, options: Array<string>) => mixed): this; |
| 85 | + choices(key: string, allowed: Array<string>): this; |
| 86 | + choices(allowed: { [key: string]: Array<string>, ... }): this; |
| 87 | + coerce(key: string, fn: (value: any) => mixed): this; |
| 88 | + coerce(object: { [key: string]: (value: any) => mixed, ... }): this; |
| 89 | + coerce(keys: Array<string>, fn: (value: any) => mixed): this; |
| 90 | + |
| 91 | + command( |
| 92 | + cmd: string | Array<string>, |
| 93 | + desc: string | false, |
| 94 | + builder?: |
| 95 | + | { [key: string]: Options, ... } |
| 96 | + | ((yargsInstance: Yargs) => mixed), |
| 97 | + handler?: Function |
| 98 | + ): this; |
| 99 | + command( |
| 100 | + cmd: string | Array<string>, |
| 101 | + desc: string | false, |
| 102 | + module: ModuleObject |
| 103 | + ): this; |
| 104 | + command(module: ModuleObject): this; |
| 105 | + |
| 106 | + commands( |
| 107 | + cmd: string | Array<string>, |
| 108 | + desc: string | false, |
| 109 | + builder?: |
| 110 | + | { [key: string]: Options, ... } |
| 111 | + | ((yargsInstance: Yargs) => mixed), |
| 112 | + handler?: Function |
| 113 | + ): this; |
| 114 | + commands( |
| 115 | + cmd: string | Array<string>, |
| 116 | + desc: string | false, |
| 117 | + module: ModuleObject |
| 118 | + ): this; |
| 119 | + commands(module: ModuleObject): this; |
| 120 | + |
| 121 | + commandDir( |
| 122 | + directory: string, |
| 123 | + options?: { |
| 124 | + exclude?: string | Function, |
| 125 | + extensions?: Array<string>, |
| 126 | + include?: string | Function, |
| 127 | + recurse?: boolean, |
| 128 | + visit?: Function, |
| 129 | + ... |
| 130 | + }, |
| 131 | + ): this; |
| 132 | + |
| 133 | + completion( |
| 134 | + cmd?: string, |
| 135 | + description?: string | false | ( |
| 136 | + current: string, |
| 137 | + argv: Argv, |
| 138 | + done: (compeltion: Array<string>) => void |
| 139 | + ) => ?(Array<string> | Promise<Array<string>>), |
| 140 | + fn?: ( |
| 141 | + current: string, |
| 142 | + argv: Argv, |
| 143 | + done: (completion: Array<string>) => void |
| 144 | + ) => ?(Array<string> | Promise<Array<string>>) |
| 145 | + ): this; |
| 146 | + |
| 147 | + config( |
| 148 | + key?: string, |
| 149 | + description?: string, |
| 150 | + parseFn?: (configPath: string) => { [key: string]: mixed, ... } |
| 151 | + ): this; |
| 152 | + config( |
| 153 | + key: string, |
| 154 | + parseFn?: (configPath: string) => { [key: string]: mixed, ... } |
| 155 | + ): this; |
| 156 | + config(config: { [key: string]: mixed, ... }): this; |
| 157 | + |
| 158 | + conflicts(key: string, value: string | Array<string>): this; |
| 159 | + conflicts(keys: { [key: string]: string | Array<string>, ... }): this; |
| 160 | + |
| 161 | + count(name: string): this; |
| 162 | + |
| 163 | + default(key: string, value: mixed, description?: string): this; |
| 164 | + default(defaults: { [key: string]: mixed, ... }): this; |
| 165 | + |
| 166 | + // Deprecated: use demandOption() and demandCommand() instead. |
| 167 | + demand(key: string, msg?: string | boolean): this; |
| 168 | + demand(count: number, max?: number, msg?: string | boolean): this; |
| 169 | + |
| 170 | + demandOption(key: string | Array<string>, msg?: string | boolean): this; |
| 171 | + |
| 172 | + demandCommand(): this; |
| 173 | + demandCommand(min: number, minMsg?: string): this; |
| 174 | + demandCommand( |
| 175 | + min: number, |
| 176 | + max: number, |
| 177 | + minMsg?: string, |
| 178 | + maxMsg?: string |
| 179 | + ): this; |
| 180 | + |
| 181 | + describe(key: string, description: string): this; |
| 182 | + describe(describeObject: { [key: string]: string, ... }): this; |
| 183 | + |
| 184 | + detectLocale(shouldDetect: boolean): this; |
| 185 | + |
| 186 | + env(prefix?: string): this; |
| 187 | + |
| 188 | + epilog(text: string): this; |
| 189 | + epilogue(text: string): this; |
| 190 | + |
| 191 | + example(cmd: string, desc?: string): this; |
| 192 | + |
| 193 | + exitProcess(enable: boolean): this; |
| 194 | + |
| 195 | + fail(fn: (failureMessage: string, err: Error, yargs: Yargs) => mixed): this; |
| 196 | + |
| 197 | + getCompletion( |
| 198 | + args: Array<string>, |
| 199 | + fn: (err: Error | null, completions: Array<string> | void) => void |
| 200 | + ): Promise<Array<string> | void>; |
| 201 | + |
| 202 | + global(globals: string | Array<string>, isGlobal?: boolean): this; |
| 203 | + |
| 204 | + group(key: string | Array<string>, groupName: string): this; |
| 205 | + |
| 206 | + help(option: boolean): this; |
| 207 | + |
| 208 | + help(option?: string, desc?: string): this; |
| 209 | + |
| 210 | + hide(key: string): this; |
| 211 | + |
| 212 | + implies(key: string, value: string | Array<string>): this; |
| 213 | + implies(keys: { [key: string]: string | Array<string>, ... }): this; |
| 214 | + |
| 215 | + locale( |
| 216 | + locale: | "de" |
| 217 | + | "en" |
| 218 | + | "es" |
| 219 | + | "fr" |
| 220 | + | "hi" |
| 221 | + | "hu" |
| 222 | + | "id" |
| 223 | + | "it" |
| 224 | + | "ja" |
| 225 | + | "ko" |
| 226 | + | "nb" |
| 227 | + | "pirate" |
| 228 | + | "pl" |
| 229 | + | "pt" |
| 230 | + | "pt_BR" |
| 231 | + | "ru" |
| 232 | + | "th" |
| 233 | + | "tr" |
| 234 | + | "zh_CN" |
| 235 | + ): this; |
| 236 | + locale(): string; |
| 237 | + |
| 238 | + middleware( |
| 239 | + middlewareCallbacks: Middleware, |
| 240 | + applyBeforeValidation?: boolean, |
| 241 | + ): this; |
| 242 | + |
| 243 | + nargs(key: string, count: number): this; |
| 244 | + |
| 245 | + normalize(key: string): this; |
| 246 | + |
| 247 | + number(key: string | Array<string>): this; |
| 248 | + |
| 249 | + option(key: string, options?: Options): this; |
| 250 | + option(optionMap: { [key: string]: Options, ... }): this; |
| 251 | + |
| 252 | + options(key: string, options?: Options): this; |
| 253 | + options(optionMap: { [key: string]: Options, ... }): this; |
| 254 | + |
| 255 | + parse( |
| 256 | + args?: string | Array<string>, |
| 257 | + context?: { [key: string]: any, ... }, |
| 258 | + parseCallback?: (err: Error, argv: Argv, output?: string) => void |
| 259 | + ): Argv | Promise<Argv>; |
| 260 | + parse( |
| 261 | + args?: string | Array<string>, |
| 262 | + parseCallback?: (err: Error, argv: Argv, output?: string) => void |
| 263 | + ): Argv | Promise<Argv>; |
| 264 | + |
| 265 | + parseAsync( |
| 266 | + args?: string | Array<string>, |
| 267 | + context?: { [key: string]: any, ... }, |
| 268 | + parseCallback?: (err: Error, argv: Argv, output?: string) => void |
| 269 | + ): Promise<Argv>; |
| 270 | + parseAsync( |
| 271 | + args?: string | Array<string>, |
| 272 | + parseCallback?: (err: Error, argv: Argv, output?: string) => void |
| 273 | + ): Promise<Argv>; |
| 274 | + |
| 275 | + parseSync( |
| 276 | + args?: string | Array<string>, |
| 277 | + context?: { [key: string]: any, ... }, |
| 278 | + parseCallback?: (err: Error, argv: Argv, output?: string) => void |
| 279 | + ): Argv; |
| 280 | + parseSync( |
| 281 | + args?: string | Array<string>, |
| 282 | + parseCallback?: (err: Error, argv: Argv, output?: string) => void |
| 283 | + ): Argv; |
| 284 | + |
| 285 | + parserConfiguration(configuration: {[key: string]: any, ...}): this; |
| 286 | + |
| 287 | + pkgConf(key: string, cwd?: string): this; |
| 288 | + |
| 289 | + positional(key: string, opt?: Options): this; |
| 290 | + |
| 291 | + recommendCommands(): this; |
| 292 | + |
| 293 | + // Alias of demand() |
| 294 | + require(key: string, msg: string | boolean): this; |
| 295 | + require(count: number, max?: number, msg?: string | boolean): this; |
| 296 | + |
| 297 | + requiresArg(key: string | Array<string>): this; |
| 298 | + |
| 299 | + scriptName(name: string): this; |
| 300 | + |
| 301 | + showCompletionScript(): this; |
| 302 | + |
| 303 | + showHelp(consoleLevel?: "error" | "warn" | "log"): this; |
| 304 | + showHelp(printCallback: (usageData: string) => void): this; |
| 305 | + |
| 306 | + showHelpOnFail(enable: boolean, message?: string): this; |
| 307 | + |
| 308 | + skipValidation(key: string): this; |
| 309 | + |
| 310 | + showVersion(consoleLevel?: "error" | "warn" | "log"): this; |
| 311 | + showVersion(printCallback: (usageData: string) => void): this; |
| 312 | + |
| 313 | + strict(enabled?: boolean): this; |
| 314 | + |
| 315 | + strictCommands(enabled?: boolean): this; |
| 316 | + |
| 317 | + strictOptions(enabled?: boolean): this; |
| 318 | + |
| 319 | + string(key: string | Array<string>): this; |
| 320 | + |
| 321 | + terminalWidth(): number; |
| 322 | + |
| 323 | + updateLocale(obj: { [key: string]: string, ... }): this; |
| 324 | + updateStrings(obj: { [key: string]: string, ... }): this; |
| 325 | + |
| 326 | + usage(message: string, opts?: { [key: string]: Options, ... }): this; |
| 327 | + |
| 328 | + version(): this; |
| 329 | + version(version: string | false): this; |
| 330 | + version(option: string | (() => string), version: string): this; |
| 331 | + version( |
| 332 | + option: string | (() => string), |
| 333 | + description: string | (() => string), |
| 334 | + version: string |
| 335 | + ): this; |
| 336 | + |
| 337 | + wrap(columns: number | null): this; |
| 338 | + } |
| 339 | + |
| 340 | + declare module.exports: Yargs; |
| 341 | +} |
0 commit comments