mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
yargs: Add array and demand types for positional arguments (#41721)
* yargs: Add array and demand types for positional arguments * Fix formatting
This commit is contained in:
parent
7a44c8e8de
commit
7ede30d4fb
4
types/yargs/index.d.ts
vendored
4
types/yargs/index.d.ts
vendored
@ -682,6 +682,8 @@ declare namespace yargs {
|
||||
interface PositionalOptions {
|
||||
/** string or array of strings, see `alias()` */
|
||||
alias?: string | ReadonlyArray<string>;
|
||||
/** boolean, interpret option as an array, see `array()` */
|
||||
array?: boolean;
|
||||
/** value or array of values, limit valid option arguments to a predefined set, see `choices()` */
|
||||
choices?: Choices;
|
||||
/** function, coerce or transform parsed command line values into another value, see `coerce()` */
|
||||
@ -690,6 +692,8 @@ declare namespace yargs {
|
||||
conflicts?: string | ReadonlyArray<string> | { [key: string]: string | ReadonlyArray<string> };
|
||||
/** value, set a default value for the option, see `default()` */
|
||||
default?: any;
|
||||
/** boolean or string, demand the option be given, with optional error message, see `demandOption()` */
|
||||
demandOption?: boolean | string;
|
||||
/** string, the option description for help content, see `describe()` */
|
||||
desc?: string;
|
||||
/** string, the option description for help content, see `describe()` */
|
||||
|
||||
1
types/yargs/v10/index.d.ts
vendored
1
types/yargs/v10/index.d.ts
vendored
@ -284,6 +284,7 @@ declare namespace yargs {
|
||||
|
||||
interface PositionalOptions {
|
||||
alias?: string | string[];
|
||||
array?: boolean;
|
||||
choices?: Choices;
|
||||
coerce?: (arg: any) => any;
|
||||
conflicts?: string | string[] | { [key: string]: string | string[] };
|
||||
|
||||
@ -298,6 +298,17 @@ function Argv$command() {
|
||||
.argv;
|
||||
}
|
||||
|
||||
function Argv$positional() {
|
||||
yargs
|
||||
.command('test [paths...]', 'run tests', yargs => {
|
||||
yargs.positional('paths', {
|
||||
type: 'string',
|
||||
array: true,
|
||||
});
|
||||
})
|
||||
.help().argv;
|
||||
}
|
||||
|
||||
function Argv$completion_sync() {
|
||||
const argv = yargs
|
||||
.completion('completion', (current, argv) => {
|
||||
|
||||
1
types/yargs/v11/index.d.ts
vendored
1
types/yargs/v11/index.d.ts
vendored
@ -299,6 +299,7 @@ declare namespace yargs {
|
||||
|
||||
interface PositionalOptions {
|
||||
alias?: string | string[];
|
||||
array?: boolean;
|
||||
choices?: Choices;
|
||||
coerce?: (arg: any) => any;
|
||||
conflicts?: string | string[] | { [key: string]: string | string[] };
|
||||
|
||||
@ -298,6 +298,17 @@ function Argv$command() {
|
||||
.argv;
|
||||
}
|
||||
|
||||
function Argv$positional() {
|
||||
yargs
|
||||
.command('test [paths...]', 'run tests', yargs => {
|
||||
yargs.positional('paths', {
|
||||
type: 'string',
|
||||
array: true,
|
||||
});
|
||||
})
|
||||
.help().argv;
|
||||
}
|
||||
|
||||
function Argv$completion_sync() {
|
||||
const argv = yargs
|
||||
.completion('completion', (current, argv) => {
|
||||
|
||||
2
types/yargs/v12/index.d.ts
vendored
2
types/yargs/v12/index.d.ts
vendored
@ -359,10 +359,12 @@ declare namespace yargs {
|
||||
|
||||
interface PositionalOptions {
|
||||
alias?: string | ReadonlyArray<string>;
|
||||
array?: boolean;
|
||||
choices?: Choices;
|
||||
coerce?: (arg: any) => any;
|
||||
conflicts?: string | ReadonlyArray<string> | { [key: string]: string | ReadonlyArray<string> };
|
||||
default?: any;
|
||||
demandOption?: boolean | string;
|
||||
desc?: string;
|
||||
describe?: string;
|
||||
description?: string;
|
||||
|
||||
@ -321,6 +321,22 @@ function Argv$command() {
|
||||
.argv;
|
||||
}
|
||||
|
||||
function Argv$positional() {
|
||||
const module: yargs.CommandModule<{}, { paths: string[] }> = {
|
||||
command: 'test <paths...>',
|
||||
builder(yargs) {
|
||||
return yargs.positional('paths', {
|
||||
type: 'string',
|
||||
array: true,
|
||||
demandOption: true
|
||||
});
|
||||
},
|
||||
handler(argv) {
|
||||
argv.paths.map((path) => path);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function Argv$commandModule() {
|
||||
class CommandOne implements yargs.CommandModule {
|
||||
handler(args: yargs.Arguments): void {
|
||||
|
||||
4
types/yargs/v13/index.d.ts
vendored
4
types/yargs/v13/index.d.ts
vendored
@ -676,6 +676,8 @@ declare namespace yargs {
|
||||
interface PositionalOptions {
|
||||
/** string or array of strings, see `alias()` */
|
||||
alias?: string | ReadonlyArray<string>;
|
||||
/** boolean, interpret option as an array, see `array()` */
|
||||
array?: boolean;
|
||||
/** value or array of values, limit valid option arguments to a predefined set, see `choices()` */
|
||||
choices?: Choices;
|
||||
/** function, coerce or transform parsed command line values into another value, see `coerce()` */
|
||||
@ -684,6 +686,8 @@ declare namespace yargs {
|
||||
conflicts?: string | ReadonlyArray<string> | { [key: string]: string | ReadonlyArray<string> };
|
||||
/** value, set a default value for the option, see `default()` */
|
||||
default?: any;
|
||||
/** boolean or string, demand the option be given, with optional error message, see `demandOption()` */
|
||||
demandOption?: boolean | string;
|
||||
/** string, the option description for help content, see `describe()` */
|
||||
desc?: string;
|
||||
/** string, the option description for help content, see `describe()` */
|
||||
|
||||
@ -322,6 +322,22 @@ function Argv$command() {
|
||||
.argv;
|
||||
}
|
||||
|
||||
function Argv$positional() {
|
||||
const module: yargs.CommandModule<{}, { paths: string[] }> = {
|
||||
command: 'test <paths...>',
|
||||
builder(yargs) {
|
||||
return yargs.positional('paths', {
|
||||
type: 'string',
|
||||
array: true,
|
||||
demandOption: true
|
||||
});
|
||||
},
|
||||
handler(argv) {
|
||||
argv.paths.map((path) => path);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function Argv$commandModule() {
|
||||
class CommandOne implements yargs.CommandModule {
|
||||
handler(args: yargs.Arguments): void {
|
||||
|
||||
@ -322,6 +322,22 @@ function Argv$command() {
|
||||
.argv;
|
||||
}
|
||||
|
||||
function Argv$positional() {
|
||||
const module: yargs.CommandModule<{}, { paths: string[] }> = {
|
||||
command: 'test <paths...>',
|
||||
builder(yargs) {
|
||||
return yargs.positional('paths', {
|
||||
type: 'string',
|
||||
array: true,
|
||||
demandOption: true
|
||||
});
|
||||
},
|
||||
handler(argv) {
|
||||
argv.paths.map((path) => path);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function Argv$commandModule() {
|
||||
class CommandOne implements yargs.CommandModule {
|
||||
handler(args: yargs.Arguments): void {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user