mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-02-04 07:52:51 +00:00
Merge pull request #34343 from forivall/forivall/yargs-non-singleton-ng
Add non-singleton version of yargs, and other things used by lerna
This commit is contained in:
commit
3502017fda
27
types/yargs/index.d.ts
vendored
27
types/yargs/index.d.ts
vendored
@ -6,6 +6,7 @@
|
||||
// Jeff Kenney <https://github.com/jeffkenney>
|
||||
// Jimi (Dimitris) Charalampidis <https://github.com/JimiC>
|
||||
// Steffen Viken Valvåg <https://github.com/steffenvv>
|
||||
// Emily Marigold Klassen <https://github.com/forivall>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 3.0
|
||||
|
||||
@ -124,6 +125,8 @@ declare namespace yargs {
|
||||
|
||||
example(command: string, description: string): Argv<T>;
|
||||
|
||||
exit(code: number, err: Error): void;
|
||||
|
||||
exitProcess(enabled: boolean): Argv<T>;
|
||||
|
||||
fail(func: (msg: string, err: Error) => any): Argv<T>;
|
||||
@ -169,6 +172,8 @@ declare namespace yargs {
|
||||
parse(): { [key in keyof Arguments<T>]: Arguments<T>[key] };
|
||||
parse(arg: string | ReadonlyArray<string>, context?: object, parseCallback?: ParseCallback<T>): { [key in keyof Arguments<T>]: Arguments<T>[key] };
|
||||
|
||||
parsed: DetailedArguments | false;
|
||||
|
||||
pkgConf(key: string | ReadonlyArray<string>, cwd?: string): Argv<T>;
|
||||
|
||||
/**
|
||||
@ -262,6 +267,28 @@ declare namespace yargs {
|
||||
[argName: string]: unknown;
|
||||
};
|
||||
|
||||
interface DetailedArguments {
|
||||
argv: Arguments;
|
||||
error: Error | null;
|
||||
aliases: {[alias: string]: string[]};
|
||||
newAliases: {[alias: string]: boolean};
|
||||
configuration: Configuration;
|
||||
}
|
||||
|
||||
interface Configuration {
|
||||
'boolean-negation': boolean;
|
||||
'camel-case-expansion': boolean;
|
||||
'combine-arrays': boolean;
|
||||
'dot-notation': boolean;
|
||||
'duplicate-arguments-array': boolean;
|
||||
'flatten-duplicate-arrays': boolean;
|
||||
'negation-prefix': string;
|
||||
'parse-numbers': boolean;
|
||||
'populate--': boolean;
|
||||
'set-placeholder-key': boolean;
|
||||
'short-option-groups': boolean;
|
||||
}
|
||||
|
||||
interface RequireDirectoryOptions {
|
||||
recurse?: boolean;
|
||||
extensions?: ReadonlyArray<string>;
|
||||
|
||||
@ -18,6 +18,7 @@
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"yargs.d.ts",
|
||||
"yargs-tests.ts"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
/// <reference types="node" />
|
||||
|
||||
import yargs = require('yargs');
|
||||
import yargsSingleton = require('yargs/yargs');
|
||||
|
||||
import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
@ -1055,3 +1056,15 @@ function Argv$fallbackToUnknownForUnknownOptions() {
|
||||
const x: string = yargs.argv.x;
|
||||
return x;
|
||||
}
|
||||
|
||||
function Argv$exit() {
|
||||
yargs.exit(1, new Error("oh no"));
|
||||
}
|
||||
|
||||
function Argv$parsed() {
|
||||
const parsedArgs = yargs.parsed;
|
||||
}
|
||||
|
||||
function makeSingleton() {
|
||||
yargsSingleton(process.argv.slice(2));
|
||||
}
|
||||
|
||||
9
types/yargs/yargs.d.ts
vendored
Normal file
9
types/yargs/yargs.d.ts
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
import { Argv } from '.';
|
||||
|
||||
export = Yargs;
|
||||
|
||||
declare function Yargs(
|
||||
processArgs?: ReadonlyArray<string>,
|
||||
cwd?: string,
|
||||
parentRequire?: NodeRequireFunction,
|
||||
): Argv;
|
||||
Loading…
Reference in New Issue
Block a user