yargs 15.3.2-beta.0 → 15.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (83) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/LICENSE +2 -3
  3. package/README.md +4 -4
  4. package/build/lib/apply-extends.d.ts +2 -2
  5. package/build/lib/apply-extends.js +2 -1
  6. package/build/lib/argsert.js +1 -0
  7. package/build/lib/command.d.ts +64 -0
  8. package/build/lib/command.js +416 -0
  9. package/build/lib/common-types.d.ts +36 -0
  10. package/build/lib/common-types.js +25 -0
  11. package/build/lib/completion-templates.js +1 -0
  12. package/build/lib/completion.d.ts +20 -1
  13. package/build/lib/completion.js +14 -5
  14. package/build/lib/is-promise.js +1 -0
  15. package/build/lib/levenshtein.js +1 -0
  16. package/build/lib/middleware.d.ts +10 -0
  17. package/build/lib/middleware.js +57 -0
  18. package/build/lib/obj-filter.d.ts +1 -2
  19. package/build/lib/obj-filter.js +4 -2
  20. package/build/lib/parse-command.d.ts +10 -1
  21. package/build/lib/parse-command.js +1 -0
  22. package/build/lib/process-argv.js +1 -0
  23. package/build/lib/usage.d.ts +48 -2
  24. package/build/lib/usage.js +19 -5
  25. package/build/lib/validation.d.ts +33 -2
  26. package/build/lib/validation.js +6 -4
  27. package/build/lib/yargs.d.ts +274 -0
  28. package/build/lib/yargs.js +1190 -0
  29. package/build/lib/yerror.js +1 -0
  30. package/package.json +5 -8
  31. package/yargs.js +2 -1291
  32. package/build/lib/type-helpers/command-builder.d.ts +0 -2
  33. package/build/lib/type-helpers/command-builder.js +0 -6
  34. package/build/lib/type-helpers/completion-function.d.ts +0 -2
  35. package/build/lib/type-helpers/completion-function.js +0 -6
  36. package/build/lib/type-helpers/index.d.ts +0 -2
  37. package/build/lib/type-helpers/index.js +0 -7
  38. package/build/lib/types/command-builder.d.ts +0 -5
  39. package/build/lib/types/command-builder.js +0 -2
  40. package/build/lib/types/command-handler.d.ts +0 -4
  41. package/build/lib/types/command-handler.js +0 -2
  42. package/build/lib/types/command-instance.d.ts +0 -7
  43. package/build/lib/types/command-instance.js +0 -2
  44. package/build/lib/types/completion-function.d.ts +0 -8
  45. package/build/lib/types/completion-function.js +0 -2
  46. package/build/lib/types/completion-instance.d.ts +0 -10
  47. package/build/lib/types/completion-instance.js +0 -2
  48. package/build/lib/types/context.d.ts +0 -4
  49. package/build/lib/types/context.js +0 -2
  50. package/build/lib/types/custom-check.d.ts +0 -5
  51. package/build/lib/types/custom-check.js +0 -2
  52. package/build/lib/types/dictionary.d.ts +0 -3
  53. package/build/lib/types/dictionary.js +0 -2
  54. package/build/lib/types/electron-process.d.ts +0 -7
  55. package/build/lib/types/electron-process.js +0 -2
  56. package/build/lib/types/failure-function.d.ts +0 -5
  57. package/build/lib/types/failure-function.js +0 -2
  58. package/build/lib/types/frozen-usage-instance.d.ts +0 -11
  59. package/build/lib/types/frozen-usage-instance.js +0 -2
  60. package/build/lib/types/frozen-validation-instance.d.ts +0 -8
  61. package/build/lib/types/frozen-validation-instance.js +0 -2
  62. package/build/lib/types/index.d.ts +0 -20
  63. package/build/lib/types/index.js +0 -2
  64. package/build/lib/types/key-or-pos.d.ts +0 -1
  65. package/build/lib/types/key-or-pos.js +0 -2
  66. package/build/lib/types/logger-instance.d.ts +0 -2
  67. package/build/lib/types/logger-instance.js +0 -2
  68. package/build/lib/types/options.d.ts +0 -19
  69. package/build/lib/types/options.js +0 -2
  70. package/build/lib/types/parsed-command.d.ts +0 -6
  71. package/build/lib/types/parsed-command.js +0 -2
  72. package/build/lib/types/parser-configuration.d.ts +0 -5
  73. package/build/lib/types/parser-configuration.js +0 -2
  74. package/build/lib/types/positional.d.ts +0 -4
  75. package/build/lib/types/positional.js +0 -2
  76. package/build/lib/types/usage-instance.d.ts +0 -37
  77. package/build/lib/types/usage-instance.js +0 -2
  78. package/build/lib/types/validation-instance.d.ts +0 -28
  79. package/build/lib/types/validation-instance.js +0 -2
  80. package/build/lib/types/yargs-instance.d.ts +0 -44
  81. package/build/lib/types/yargs-instance.js +0 -2
  82. package/lib/command.js +0 -435
  83. package/lib/middleware.js +0 -64
@@ -1,2 +0,0 @@
1
- import { CommandBuilder, FunctionCommandBuilder } from '../types';
2
- export declare function isFunctionCommandBuilder(builder: CommandBuilder): builder is FunctionCommandBuilder;
@@ -1,6 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- function isFunctionCommandBuilder(builder) {
4
- return typeof builder === 'function';
5
- }
6
- exports.isFunctionCommandBuilder = isFunctionCommandBuilder;
@@ -1,2 +0,0 @@
1
- import { CompletionFunction, SyncCompletionFunction } from '../types';
2
- export declare function isSyncCompletionFunction(completionFunction: CompletionFunction): completionFunction is SyncCompletionFunction;
@@ -1,6 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- function isSyncCompletionFunction(completionFunction) {
4
- return completionFunction.length < 3;
5
- }
6
- exports.isSyncCompletionFunction = isSyncCompletionFunction;
@@ -1,2 +0,0 @@
1
- export * from './completion-function';
2
- export * from './command-builder';
@@ -1,7 +0,0 @@
1
- "use strict";
2
- function __export(m) {
3
- for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
4
- }
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- __export(require("./completion-function"));
7
- __export(require("./command-builder"));
@@ -1,5 +0,0 @@
1
- import { YargsInstance } from './yargs-instance';
2
- export declare type CommandBuilder = FunctionCommandBuilder;
3
- export interface FunctionCommandBuilder {
4
- (y: YargsInstance): YargsInstance;
5
- }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,4 +0,0 @@
1
- import { CommandBuilder } from './command-builder';
2
- export interface CommandHandler {
3
- builder: CommandBuilder;
4
- }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,7 +0,0 @@
1
- import { CommandHandler } from './command-handler';
2
- import { Dictionary } from './dictionary';
3
- /** Instance of the command module. */
4
- export interface CommandInstance {
5
- getCommandHandlers(): Dictionary<CommandHandler>;
6
- getCommands(): string[];
7
- }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,8 +0,0 @@
1
- import { Arguments } from 'yargs-parser';
2
- export declare type CompletionFunction = SyncCompletionFunction | AsyncCompletionFunction;
3
- export interface SyncCompletionFunction {
4
- (current: string, argv: Arguments): string[] | Promise<string[]>;
5
- }
6
- export interface AsyncCompletionFunction {
7
- (current: string, argv: Arguments, done: (completions: string[]) => any): any;
8
- }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,10 +0,0 @@
1
- import { CompletionFunction } from './completion-function';
2
- import { DetailedArguments } from 'yargs-parser';
3
- /** Instance of the completion module. */
4
- export interface CompletionInstance {
5
- completionKey: string;
6
- generateCompletionScript($0: string, cmd: string): string;
7
- getCompletion(args: string[], done: (completions: string[]) => any): any;
8
- registerFunction(fn: CompletionFunction): void;
9
- setParsed(parsed: DetailedArguments): void;
10
- }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,4 +0,0 @@
1
- /** Yargs' context. */
2
- export interface Context {
3
- commands: string[];
4
- }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,5 +0,0 @@
1
- import { Arguments, DetailedArguments } from 'yargs-parser';
2
- export interface CustomCheck {
3
- func: (argv: Arguments, aliases: DetailedArguments['aliases']) => any;
4
- global: boolean;
5
- }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,3 +0,0 @@
1
- export declare type Dictionary<T = any> = {
2
- [key: string]: T;
3
- };
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,7 +0,0 @@
1
- /// <reference types="node" />
2
- export interface ElectronProcess extends NodeJS.Process {
3
- defaultApp?: boolean;
4
- versions: NodeJS.ProcessVersions & {
5
- electron: string;
6
- };
7
- }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,5 +0,0 @@
1
- import { UsageInstance } from './usage-instance';
2
- import { YError } from '../yerror';
3
- export interface FailureFunction {
4
- (msg: string | undefined | null, err: YError | string | undefined, usage: UsageInstance): void;
5
- }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,11 +0,0 @@
1
- import { Dictionary } from './dictionary';
2
- export interface FrozenUsageInstance {
3
- failMessage: string | undefined | null;
4
- failureOutput: boolean;
5
- usages: [string, string][];
6
- usageDisabled: boolean;
7
- epilogs: string[];
8
- examples: [string, string][];
9
- commands: [string, string, boolean, string[]][];
10
- descriptions: Dictionary<string | undefined>;
11
- }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,8 +0,0 @@
1
- import { CustomCheck } from './custom-check';
2
- import { Dictionary } from './dictionary';
3
- import { KeyOrPos } from './key-or-pos';
4
- export interface FrozenValidationInstance {
5
- implied: Dictionary<KeyOrPos[]>;
6
- checks: CustomCheck[];
7
- conflicting: Dictionary<(string | undefined)[]>;
8
- }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,20 +0,0 @@
1
- export * from './command-builder';
2
- export * from './command-handler';
3
- export * from './command-instance';
4
- export * from './completion-function';
5
- export * from './completion-instance';
6
- export * from './custom-check';
7
- export * from './context';
8
- export * from './dictionary';
9
- export * from './electron-process';
10
- export * from './failure-function';
11
- export * from './frozen-usage-instance';
12
- export * from './frozen-validation-instance';
13
- export * from './key-or-pos';
14
- export * from './logger-instance';
15
- export * from './options';
16
- export * from './parsed-command';
17
- export * from './parser-configuration';
18
- export * from './usage-instance';
19
- export * from './validation-instance';
20
- export * from './yargs-instance';
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1 +0,0 @@
1
- export declare type KeyOrPos = string | number | undefined;
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,2 +0,0 @@
1
- /// <reference types="node" />
2
- export declare type LoggerInstance = Pick<Console, 'error' | 'log'>;
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,19 +0,0 @@
1
- import { Dictionary } from './dictionary';
2
- import { ParserConfiguration } from './parser-configuration';
3
- export interface Options {
4
- array: string[];
5
- alias: Dictionary<string[]>;
6
- boolean: string[];
7
- choices: Dictionary<string[]>;
8
- configuration: ParserConfiguration;
9
- count: string[];
10
- default: Dictionary;
11
- defaultDescription: Dictionary<string | undefined>;
12
- hiddenOptions: string[];
13
- /** Manually set keys */
14
- key: Dictionary<boolean>;
15
- normalize: string[];
16
- number: string[];
17
- showHiddenOpt: string;
18
- string: string[];
19
- }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,6 +0,0 @@
1
- import { Positional } from './positional';
2
- export interface ParsedCommand {
3
- cmd: string;
4
- demanded: Positional[];
5
- optional: Positional[];
6
- }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,5 +0,0 @@
1
- import yargsParser = require('yargs-parser');
2
- export interface ParserConfiguration extends yargsParser.Configuration {
3
- /** Should command be sorted in help */
4
- 'sort-commands': boolean;
5
- }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,4 +0,0 @@
1
- export interface Positional {
2
- cmd: string[];
3
- variadic: boolean;
4
- }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,37 +0,0 @@
1
- import { Dictionary } from './dictionary';
2
- import { FailureFunction } from './failure-function';
3
- import { YError } from '../yerror';
4
- /** Instance of the usage module. */
5
- export interface UsageInstance {
6
- cacheHelpMessage(): void;
7
- clearCachedHelpMessage(): void;
8
- command(cmd: string, description: string | undefined, isDefault: boolean, aliases: string[]): void;
9
- deferY18nLookup(str: string): string;
10
- describe(key: string, desc?: string): void;
11
- describe(keys: Dictionary<string>): void;
12
- epilog(msg: string): void;
13
- example(cmd: string, description?: string): void;
14
- fail(msg?: string | null, err?: YError | string): void;
15
- failFn(f: FailureFunction): void;
16
- freeze(): void;
17
- functionDescription(fn: {
18
- name?: string;
19
- }): string;
20
- getCommands(): [string, string, boolean, string[]][];
21
- getDescriptions(): Dictionary<string | undefined>;
22
- getPositionalGroupName(): string;
23
- getUsage(): [string, string][];
24
- getUsageDisabled(): boolean;
25
- help(): string;
26
- reset(localLookup: Dictionary<boolean>): UsageInstance;
27
- showHelp(level: 'error' | 'log'): void;
28
- showHelp(level: (message: string) => void): void;
29
- showHelpOnFail(message?: string): UsageInstance;
30
- showHelpOnFail(enabled: boolean, message: string): UsageInstance;
31
- showVersion(): void;
32
- stringifiedValues(values?: any[], separator?: string): string;
33
- unfreeze(): void;
34
- usage(msg: string | null, description?: string): UsageInstance;
35
- version(ver: any): void;
36
- wrap(cols: number): void;
37
- }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,28 +0,0 @@
1
- import { CustomCheck } from './custom-check';
2
- import { Dictionary } from './dictionary';
3
- import { KeyOrPos } from './key-or-pos';
4
- import { Arguments, DetailedArguments } from 'yargs-parser';
5
- /** Instance of the validation module. */
6
- export interface ValidationInstance {
7
- check(f: CustomCheck['func'], global: boolean): void;
8
- conflicting(argv: Arguments): void;
9
- conflicts(key: string, value: string | string[]): void;
10
- conflicts(key: Dictionary<string | string[]>): void;
11
- customChecks(argv: Arguments, aliases: DetailedArguments['aliases']): void;
12
- freeze(): void;
13
- getConflicting(): Dictionary<(string | undefined)[]>;
14
- getImplied(): Dictionary<KeyOrPos[]>;
15
- implications(argv: Arguments): void;
16
- implies(key: string, value: KeyOrPos | KeyOrPos[]): void;
17
- implies(key: Dictionary<KeyOrPos | KeyOrPos[]>): void;
18
- isValidAndSomeAliasIsNotNew(key: string, aliases: DetailedArguments['aliases']): boolean;
19
- limitedChoices(argv: Arguments): void;
20
- nonOptionCount(argv: Arguments): void;
21
- positionalCount(required: number, observed: number): void;
22
- recommendCommands(cmd: string, potentialCommands: string[]): void;
23
- requiredArguments(argv: Arguments): void;
24
- reset(localLookup: Dictionary): ValidationInstance;
25
- unfreeze(): void;
26
- unknownArguments(argv: Arguments, aliases: DetailedArguments['aliases'], positionalMap: Dictionary): void;
27
- unknownCommands(argv: Arguments): boolean;
28
- }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,44 +0,0 @@
1
- import { CommandInstance } from './command-instance';
2
- import { Context } from './context';
3
- import { Dictionary } from './dictionary';
4
- import { LoggerInstance } from './logger-instance';
5
- import { Options } from './options';
6
- import { ParserConfiguration } from './parser-configuration';
7
- import { YError } from '../yerror';
8
- import { Arguments, DetailedArguments } from 'yargs-parser';
9
- /** Instance of the yargs module. */
10
- export interface YargsInstance {
11
- $0: string;
12
- argv: Arguments;
13
- customScriptName: boolean;
14
- parsed: DetailedArguments;
15
- _getLoggerInstance(): LoggerInstance;
16
- _getParseContext(): Object;
17
- _hasParseCallback(): boolean;
18
- array(key: string): YargsInstance;
19
- boolean(key: string): YargsInstance;
20
- count(key: string): YargsInstance;
21
- demandOption(key: string, msg: string): YargsInstance;
22
- exit(code: number, err?: YError | string): void;
23
- getCommandInstance(): CommandInstance;
24
- getContext(): Context;
25
- getDemandedOptions(): Dictionary<string>;
26
- getDemandedCommands(): Dictionary<{
27
- min: number;
28
- max: number;
29
- minMsg?: string | null;
30
- maxMsg?: string | null;
31
- }>;
32
- getDeprecatedOptions(): Dictionary<string | boolean>;
33
- getExitProcess(): boolean;
34
- getGroups(): Dictionary<string[]>;
35
- getOptions(): Options;
36
- getParserConfiguration(): ParserConfiguration;
37
- global(globals: string | string[], global?: boolean): YargsInstance;
38
- normalize(key: string): YargsInstance;
39
- number(key: string): YargsInstance;
40
- parse(args: string[], shortCircuit: boolean): Arguments;
41
- reset(): YargsInstance;
42
- showHelp(level: string): YargsInstance;
43
- string(key: string): YargsInstance;
44
- }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });