yargs: Add 'sort-commands' option to parserConfiguration (#41718)

* Add 'sort-commands' option to `parserConfiguration`

* Use defined type instead of inline in the generic
This commit is contained in:
Cameron Hunter
2020-01-27 10:54:55 -08:00
committed by Wesley Wigham
parent 217d81c806
commit 1c51f0ffc4
4 changed files with 14 additions and 2 deletions
+6 -1
View File
@@ -30,6 +30,11 @@ import { DetailedArguments, Configuration } from 'yargs-parser';
declare namespace yargs {
type BuilderCallback<T, R> = ((args: Argv<T>) => Argv<R>) | ((args: Argv<T>) => void);
type ParserConfigurationOptions = Configuration & {
/** Sort commands alphabetically. Default is `false` */
'sort-commands': boolean;
};
/**
* The type parameter `T` is the expected shape of the parsed options.
* `Arguments<T>` is those options plus `_` and `$0`, and an indexer falling
@@ -427,7 +432,7 @@ declare namespace yargs {
parsed: DetailedArguments | false;
/** Allows to configure advanced yargs features. */
parserConfiguration(configuration: Partial<Configuration>): Argv<T>;
parserConfiguration(configuration: Partial<ParserConfigurationOptions>): Argv<T>;
/**
* Similar to `config()`, indicates that yargs should interpret the object from the specified key in package.json as a configuration object.
+6 -1
View File
@@ -30,6 +30,11 @@ import { DetailedArguments, Configuration } from 'yargs-parser';
declare namespace yargs {
type BuilderCallback<T, R> = ((args: Argv<T>) => Argv<R>) | ((args: Argv<T>) => void);
type ParserConfigurationOptions = Configuration & {
/** Sort commands alphabetically. Default is `false` */
'sort-commands': boolean;
};
/**
* The type parameter `T` is the expected shape of the parsed options.
* `Arguments<T>` is those options plus `_` and `$0`, and an indexer falling
@@ -421,7 +426,7 @@ declare namespace yargs {
parsed: DetailedArguments | false;
/** Allows to configure advanced yargs features. */
parserConfiguration(configuration: Partial<Configuration>): Argv<T>;
parserConfiguration(configuration: Partial<ParserConfigurationOptions>): Argv<T>;
/**
* Similar to `config()`, indicates that yargs should interpret the object from the specified key in package.json as a configuration object.
+1
View File
@@ -735,6 +735,7 @@ function Argv$parserConfiguration() {
'populate--': false,
'set-placeholder-key': false,
'short-option-groups': false,
'sort-commands': true,
}).parse();
const argv2 = yargs.parserConfiguration({
+1
View File
@@ -735,6 +735,7 @@ function Argv$parserConfiguration() {
'populate--': false,
'set-placeholder-key': false,
'short-option-groups': false,
'sort-commands': true,
}).parse();
const argv2 = yargs.parserConfiguration({