@bemoje/cli 0.0.11 → 0.0.13
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.
- package/cjs/arg/ArgumentBuilder.js +15 -0
- package/cjs/arg/ArgumentBuilder.js.map +1 -1
- package/cjs/cmd/CommandBuilder.js +196 -70
- package/cjs/cmd/CommandBuilder.js.map +1 -1
- package/cjs/cmd/CommandBuilderMetaData.js +1 -0
- package/cjs/cmd/CommandBuilderMetaData.js.map +1 -1
- package/cjs/cmd/DefaultHelpConfig.js +1 -0
- package/cjs/cmd/DefaultHelpConfig.js.map +1 -1
- package/cjs/db/JsonFile.js +1 -1
- package/cjs/index.js +28 -0
- package/cjs/index.js.map +1 -1
- package/cjs/opt/OptionBuilder.js +6 -0
- package/cjs/opt/OptionBuilder.js.map +1 -1
- package/cjs/prompt/additions/commandSearchPrompt/commandSearchPrompt.js +39 -0
- package/cjs/prompt/additions/commandSearchPrompt/commandSearchPrompt.js.map +1 -0
- package/cjs/prompt/additions/commandSearchPrompt/core/ICommandSearchPromptResult.js +3 -0
- package/cjs/prompt/additions/commandSearchPrompt/core/ICommandSearchPromptResult.js.map +1 -0
- package/cjs/prompt/additions/commandSearchPrompt/core/createCommandSearchPromptObject.js +34 -0
- package/cjs/prompt/additions/commandSearchPrompt/core/createCommandSearchPromptObject.js.map +1 -0
- package/cjs/prompt/additions/searchPrompt/core/ISearchPromptChoiceMetaData.js +3 -0
- package/cjs/prompt/additions/searchPrompt/core/ISearchPromptChoiceMetaData.js.map +1 -0
- package/cjs/prompt/additions/searchPrompt/core/ISearchPromptMetaData.js +3 -0
- package/cjs/prompt/additions/searchPrompt/core/ISearchPromptMetaData.js.map +1 -0
- package/cjs/prompt/additions/searchPrompt/core/ISearchPromptOptions.js +3 -0
- package/cjs/prompt/additions/searchPrompt/core/ISearchPromptOptions.js.map +1 -0
- package/cjs/prompt/additions/searchPrompt/core/ISearchPromptResult.js +3 -0
- package/cjs/prompt/additions/searchPrompt/core/ISearchPromptResult.js.map +1 -0
- package/cjs/prompt/additions/searchPrompt/core/PROMPT_META_DATA.js +5 -0
- package/cjs/prompt/additions/searchPrompt/core/PROMPT_META_DATA.js.map +1 -0
- package/cjs/prompt/additions/searchPrompt/core/createSearchPromptObject.js +177 -0
- package/cjs/prompt/additions/searchPrompt/core/createSearchPromptObject.js.map +1 -0
- package/cjs/prompt/additions/searchPrompt/core/getSearchPromptMetaData.js +12 -0
- package/cjs/prompt/additions/searchPrompt/core/getSearchPromptMetaData.js.map +1 -0
- package/cjs/prompt/additions/searchPrompt/searchPrompt.js +37 -0
- package/cjs/prompt/additions/searchPrompt/searchPrompt.js.map +1 -0
- package/cjs/prompt/core/AbstractUserPrompt.js +88 -0
- package/cjs/prompt/core/AbstractUserPrompt.js.map +1 -0
- package/cjs/prompt/core/AutoCompleteMultiSelectPrompt.js +90 -0
- package/cjs/prompt/core/AutoCompleteMultiSelectPrompt.js.map +1 -0
- package/cjs/prompt/core/AutocompletePrompt.js +111 -0
- package/cjs/prompt/core/AutocompletePrompt.js.map +1 -0
- package/cjs/prompt/core/ConfirmPrompt.js +34 -0
- package/cjs/prompt/core/ConfirmPrompt.js.map +1 -0
- package/cjs/prompt/core/DatePrompt.js +58 -0
- package/cjs/prompt/core/DatePrompt.js.map +1 -0
- package/cjs/prompt/core/InvisiblePrompt.js +49 -0
- package/cjs/prompt/core/InvisiblePrompt.js.map +1 -0
- package/cjs/prompt/core/ListPrompt.js +56 -0
- package/cjs/prompt/core/ListPrompt.js.map +1 -0
- package/cjs/prompt/core/MultiSelectPrompt.js +90 -0
- package/cjs/prompt/core/MultiSelectPrompt.js.map +1 -0
- package/cjs/prompt/core/NumberPrompt.js +70 -0
- package/cjs/prompt/core/NumberPrompt.js.map +1 -0
- package/cjs/prompt/core/PasswordPrompt.js +49 -0
- package/cjs/prompt/core/PasswordPrompt.js.map +1 -0
- package/cjs/prompt/core/SearchPrompt.js +112 -0
- package/cjs/prompt/core/SearchPrompt.js.map +1 -0
- package/cjs/prompt/core/SelectPrompt.js +62 -0
- package/cjs/prompt/core/SelectPrompt.js.map +1 -0
- package/cjs/prompt/core/TextPrompt.js +49 -0
- package/cjs/prompt/core/TextPrompt.js.map +1 -0
- package/cjs/prompt/core/TogglePrompt.js +48 -0
- package/cjs/prompt/core/TogglePrompt.js.map +1 -0
- package/cjs/prompt/core/types.js +3 -0
- package/cjs/prompt/core/types.js.map +1 -0
- package/cjs/prompt/example.js +117 -0
- package/cjs/prompt/example.js.map +1 -0
- package/cjs/prompt/prompt.js +62 -0
- package/cjs/prompt/prompt.js.map +1 -0
- package/esm/arg/ArgumentBuilder.js +15 -0
- package/esm/arg/ArgumentBuilder.js.map +1 -1
- package/esm/cmd/CommandBuilder.js +196 -70
- package/esm/cmd/CommandBuilder.js.map +1 -1
- package/esm/cmd/CommandBuilderMetaData.js +1 -0
- package/esm/cmd/CommandBuilderMetaData.js.map +1 -1
- package/esm/cmd/DefaultHelpConfig.js +1 -0
- package/esm/cmd/DefaultHelpConfig.js.map +1 -1
- package/esm/db/JsonFile.js +1 -1
- package/esm/index.js +28 -0
- package/esm/index.js.map +1 -1
- package/esm/opt/OptionBuilder.js +6 -0
- package/esm/opt/OptionBuilder.js.map +1 -1
- package/esm/prompt/additions/commandSearchPrompt/commandSearchPrompt.js +32 -0
- package/esm/prompt/additions/commandSearchPrompt/commandSearchPrompt.js.map +1 -0
- package/esm/prompt/additions/commandSearchPrompt/core/ICommandSearchPromptResult.js +2 -0
- package/esm/prompt/additions/commandSearchPrompt/core/ICommandSearchPromptResult.js.map +1 -0
- package/esm/prompt/additions/commandSearchPrompt/core/createCommandSearchPromptObject.js +27 -0
- package/esm/prompt/additions/commandSearchPrompt/core/createCommandSearchPromptObject.js.map +1 -0
- package/esm/prompt/additions/searchPrompt/core/ISearchPromptChoiceMetaData.js +2 -0
- package/esm/prompt/additions/searchPrompt/core/ISearchPromptChoiceMetaData.js.map +1 -0
- package/esm/prompt/additions/searchPrompt/core/ISearchPromptMetaData.js +2 -0
- package/esm/prompt/additions/searchPrompt/core/ISearchPromptMetaData.js.map +1 -0
- package/esm/prompt/additions/searchPrompt/core/ISearchPromptOptions.js +2 -0
- package/esm/prompt/additions/searchPrompt/core/ISearchPromptOptions.js.map +1 -0
- package/esm/prompt/additions/searchPrompt/core/ISearchPromptResult.js +2 -0
- package/esm/prompt/additions/searchPrompt/core/ISearchPromptResult.js.map +1 -0
- package/esm/prompt/additions/searchPrompt/core/PROMPT_META_DATA.js +2 -0
- package/esm/prompt/additions/searchPrompt/core/PROMPT_META_DATA.js.map +1 -0
- package/esm/prompt/additions/searchPrompt/core/createSearchPromptObject.js +173 -0
- package/esm/prompt/additions/searchPrompt/core/createSearchPromptObject.js.map +1 -0
- package/esm/prompt/additions/searchPrompt/core/getSearchPromptMetaData.js +8 -0
- package/esm/prompt/additions/searchPrompt/core/getSearchPromptMetaData.js.map +1 -0
- package/esm/prompt/additions/searchPrompt/searchPrompt.js +30 -0
- package/esm/prompt/additions/searchPrompt/searchPrompt.js.map +1 -0
- package/esm/prompt/core/AbstractUserPrompt.js +81 -0
- package/esm/prompt/core/AbstractUserPrompt.js.map +1 -0
- package/esm/prompt/core/AutoCompleteMultiSelectPrompt.js +86 -0
- package/esm/prompt/core/AutoCompleteMultiSelectPrompt.js.map +1 -0
- package/esm/prompt/core/AutocompletePrompt.js +107 -0
- package/esm/prompt/core/AutocompletePrompt.js.map +1 -0
- package/esm/prompt/core/ConfirmPrompt.js +30 -0
- package/esm/prompt/core/ConfirmPrompt.js.map +1 -0
- package/esm/prompt/core/DatePrompt.js +54 -0
- package/esm/prompt/core/DatePrompt.js.map +1 -0
- package/esm/prompt/core/InvisiblePrompt.js +45 -0
- package/esm/prompt/core/InvisiblePrompt.js.map +1 -0
- package/esm/prompt/core/ListPrompt.js +52 -0
- package/esm/prompt/core/ListPrompt.js.map +1 -0
- package/esm/prompt/core/MultiSelectPrompt.js +86 -0
- package/esm/prompt/core/MultiSelectPrompt.js.map +1 -0
- package/esm/prompt/core/NumberPrompt.js +66 -0
- package/esm/prompt/core/NumberPrompt.js.map +1 -0
- package/esm/prompt/core/PasswordPrompt.js +45 -0
- package/esm/prompt/core/PasswordPrompt.js.map +1 -0
- package/esm/prompt/core/SearchPrompt.js +108 -0
- package/esm/prompt/core/SearchPrompt.js.map +1 -0
- package/esm/prompt/core/SelectPrompt.js +58 -0
- package/esm/prompt/core/SelectPrompt.js.map +1 -0
- package/esm/prompt/core/TextPrompt.js +45 -0
- package/esm/prompt/core/TextPrompt.js.map +1 -0
- package/esm/prompt/core/TogglePrompt.js +44 -0
- package/esm/prompt/core/TogglePrompt.js.map +1 -0
- package/esm/prompt/core/types.js +2 -0
- package/esm/prompt/core/types.js.map +1 -0
- package/esm/prompt/example.js +112 -0
- package/esm/prompt/example.js.map +1 -0
- package/esm/prompt/prompt.js +59 -0
- package/esm/prompt/prompt.js.map +1 -0
- package/package.json +1 -1
- package/types/arg/ArgumentBuilder.d.ts +14 -0
- package/types/arg/ArgumentBuilder.d.ts.map +1 -0
- package/types/arg/ArgumentParserSelector.d.ts +1 -0
- package/types/arg/ArgumentParserSelector.d.ts.map +1 -0
- package/types/arg/ArgumentReader.d.ts +1 -0
- package/types/arg/ArgumentReader.d.ts.map +1 -0
- package/types/arg/ArgumentValidatorSelector.d.ts +1 -0
- package/types/arg/ArgumentValidatorSelector.d.ts.map +1 -0
- package/types/cmd/CommandBuilder.d.ts +152 -46
- package/types/cmd/CommandBuilder.d.ts.map +1 -0
- package/types/cmd/CommandBuilderMetaData.d.ts +3 -0
- package/types/cmd/CommandBuilderMetaData.d.ts.map +1 -0
- package/types/cmd/CommandFeatureSelector.d.ts +1 -0
- package/types/cmd/CommandFeatureSelector.d.ts.map +1 -0
- package/types/cmd/DefaultHelpConfig.d.ts +1 -0
- package/types/cmd/DefaultHelpConfig.d.ts.map +1 -0
- package/types/core/OutputManager.d.ts +1 -0
- package/types/core/OutputManager.d.ts.map +1 -0
- package/types/core/ParserSelector.d.ts +1 -0
- package/types/core/ParserSelector.d.ts.map +1 -0
- package/types/core/ValidatorSelector.d.ts +1 -0
- package/types/core/ValidatorSelector.d.ts.map +1 -0
- package/types/core/splitCombinedArgvShorts.d.ts +1 -0
- package/types/core/splitCombinedArgvShorts.d.ts.map +1 -0
- package/types/db/AbstractJsonFileSection.d.ts +1 -0
- package/types/db/AbstractJsonFileSection.d.ts.map +1 -0
- package/types/db/AppDataSection.d.ts +1 -0
- package/types/db/AppDataSection.d.ts.map +1 -0
- package/types/db/ConfigSection.d.ts +1 -0
- package/types/db/ConfigSection.d.ts.map +1 -0
- package/types/db/JsonFile.d.ts +1 -0
- package/types/db/JsonFile.d.ts.map +1 -0
- package/types/db/PresetsSection.d.ts +1 -0
- package/types/db/PresetsSection.d.ts.map +1 -0
- package/types/index.d.ts +29 -0
- package/types/index.d.ts.map +1 -0
- package/types/opt/OptionArgumentParserSelector.d.ts +1 -0
- package/types/opt/OptionArgumentParserSelector.d.ts.map +1 -0
- package/types/opt/OptionArgumentValidatorSelector.d.ts +1 -0
- package/types/opt/OptionArgumentValidatorSelector.d.ts.map +1 -0
- package/types/opt/OptionBuilder.d.ts +3 -0
- package/types/opt/OptionBuilder.d.ts.map +1 -0
- package/types/opt/OptionHelpers.d.ts +1 -0
- package/types/opt/OptionHelpers.d.ts.map +1 -0
- package/types/opt/OptionReader.d.ts +1 -0
- package/types/opt/OptionReader.d.ts.map +1 -0
- package/types/prompt/additions/commandSearchPrompt/commandSearchPrompt.d.ts +21 -0
- package/types/prompt/additions/commandSearchPrompt/commandSearchPrompt.d.ts.map +1 -0
- package/types/prompt/additions/commandSearchPrompt/core/ICommandSearchPromptResult.d.ts +5 -0
- package/types/prompt/additions/commandSearchPrompt/core/ICommandSearchPromptResult.d.ts.map +1 -0
- package/types/prompt/additions/commandSearchPrompt/core/createCommandSearchPromptObject.d.ts +13 -0
- package/types/prompt/additions/commandSearchPrompt/core/createCommandSearchPromptObject.d.ts.map +1 -0
- package/types/prompt/additions/searchPrompt/core/ISearchPromptChoiceMetaData.d.ts +5 -0
- package/types/prompt/additions/searchPrompt/core/ISearchPromptChoiceMetaData.d.ts.map +1 -0
- package/types/prompt/additions/searchPrompt/core/ISearchPromptMetaData.d.ts +9 -0
- package/types/prompt/additions/searchPrompt/core/ISearchPromptMetaData.d.ts.map +1 -0
- package/types/prompt/additions/searchPrompt/core/ISearchPromptOptions.d.ts +44 -0
- package/types/prompt/additions/searchPrompt/core/ISearchPromptOptions.d.ts.map +1 -0
- package/types/prompt/additions/searchPrompt/core/ISearchPromptResult.d.ts +6 -0
- package/types/prompt/additions/searchPrompt/core/ISearchPromptResult.d.ts.map +1 -0
- package/types/prompt/additions/searchPrompt/core/PROMPT_META_DATA.d.ts +4 -0
- package/types/prompt/additions/searchPrompt/core/PROMPT_META_DATA.d.ts.map +1 -0
- package/types/prompt/additions/searchPrompt/core/createSearchPromptObject.d.ts +13 -0
- package/types/prompt/additions/searchPrompt/core/createSearchPromptObject.d.ts.map +1 -0
- package/types/prompt/additions/searchPrompt/core/getSearchPromptMetaData.d.ts +4 -0
- package/types/prompt/additions/searchPrompt/core/getSearchPromptMetaData.d.ts.map +1 -0
- package/types/prompt/additions/searchPrompt/searchPrompt.d.ts +21 -0
- package/types/prompt/additions/searchPrompt/searchPrompt.d.ts.map +1 -0
- package/types/prompt/core/AbstractUserPrompt.d.ts +55 -0
- package/types/prompt/core/AbstractUserPrompt.d.ts.map +1 -0
- package/types/prompt/core/AutoCompleteMultiSelectPrompt.d.ts +54 -0
- package/types/prompt/core/AutoCompleteMultiSelectPrompt.d.ts.map +1 -0
- package/types/prompt/core/AutocompletePrompt.d.ts +66 -0
- package/types/prompt/core/AutocompletePrompt.d.ts.map +1 -0
- package/types/prompt/core/ConfirmPrompt.d.ts +21 -0
- package/types/prompt/core/ConfirmPrompt.d.ts.map +1 -0
- package/types/prompt/core/DatePrompt.d.ts +37 -0
- package/types/prompt/core/DatePrompt.d.ts.map +1 -0
- package/types/prompt/core/InvisiblePrompt.d.ts +30 -0
- package/types/prompt/core/InvisiblePrompt.d.ts.map +1 -0
- package/types/prompt/core/ListPrompt.d.ts +34 -0
- package/types/prompt/core/ListPrompt.d.ts.map +1 -0
- package/types/prompt/core/MultiSelectPrompt.d.ts +54 -0
- package/types/prompt/core/MultiSelectPrompt.d.ts.map +1 -0
- package/types/prompt/core/NumberPrompt.d.ts +42 -0
- package/types/prompt/core/NumberPrompt.d.ts.map +1 -0
- package/types/prompt/core/PasswordPrompt.d.ts +30 -0
- package/types/prompt/core/PasswordPrompt.d.ts.map +1 -0
- package/types/prompt/core/SearchPrompt.d.ts +71 -0
- package/types/prompt/core/SearchPrompt.d.ts.map +1 -0
- package/types/prompt/core/SelectPrompt.d.ts +38 -0
- package/types/prompt/core/SelectPrompt.d.ts.map +1 -0
- package/types/prompt/core/TextPrompt.d.ts +30 -0
- package/types/prompt/core/TextPrompt.d.ts.map +1 -0
- package/types/prompt/core/TogglePrompt.d.ts +29 -0
- package/types/prompt/core/TogglePrompt.d.ts.map +1 -0
- package/types/prompt/core/types.d.ts +215 -0
- package/types/prompt/core/types.d.ts.map +1 -0
- package/types/prompt/example.d.ts +2 -0
- package/types/prompt/example.d.ts.map +1 -0
- package/types/prompt/prompt.d.ts +33 -0
- package/types/prompt/prompt.d.ts.map +1 -0
- package/types/types/IConfig.d.ts +1 -0
- package/types/types/IConfig.d.ts.map +1 -0
- package/types/types/IPreset.d.ts +1 -0
- package/types/types/IPreset.d.ts.map +1 -0
|
@@ -13,11 +13,19 @@ class ArgumentBuilder {
|
|
|
13
13
|
cmd;
|
|
14
14
|
$;
|
|
15
15
|
index;
|
|
16
|
+
userConfirmation;
|
|
16
17
|
constructor(cmd, name) {
|
|
17
18
|
this.cmd = cmd;
|
|
18
19
|
this.$ = new extra_typings_1.Argument(name);
|
|
19
20
|
this.index = cmd.meta.argValidators.length;
|
|
20
21
|
cmd.meta.argValidators[this.index] = [];
|
|
22
|
+
this.cmd.meta.argBuilders.push(this);
|
|
23
|
+
}
|
|
24
|
+
get hasValidators() {
|
|
25
|
+
return this.cmd.meta.argValidators[this.index].length > 0;
|
|
26
|
+
}
|
|
27
|
+
get hasParser() {
|
|
28
|
+
return this.cmd.meta.argParsers[this.index] !== undefined;
|
|
21
29
|
}
|
|
22
30
|
description(string) {
|
|
23
31
|
this.$.description = string;
|
|
@@ -40,6 +48,13 @@ class ArgumentBuilder {
|
|
|
40
48
|
get get() {
|
|
41
49
|
return (0, util_1.realizeLazyProperty)(this, 'get', new ArgumentReader_1.ArgumentReader(this));
|
|
42
50
|
}
|
|
51
|
+
/**
|
|
52
|
+
* Only works with async actionHandlers.
|
|
53
|
+
*/
|
|
54
|
+
userMustConfirmIf(options) {
|
|
55
|
+
this.userConfirmation = options;
|
|
56
|
+
return this;
|
|
57
|
+
}
|
|
43
58
|
}
|
|
44
59
|
exports.ArgumentBuilder = ArgumentBuilder;
|
|
45
60
|
//# sourceMappingURL=ArgumentBuilder.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ArgumentBuilder.js","sourceRoot":"","sources":["../../../../../packages/cli/src/arg/ArgumentBuilder.ts"],"names":[],"mappings":";;;AAAA,+DAAsD;AACtD,qEAAiE;AACjE,qDAAiD;AACjD,2EAAuE;AAEvE,uCAAkD;AAElD;;GAEG;AACH,MAAa,eAAe;
|
|
1
|
+
{"version":3,"file":"ArgumentBuilder.js","sourceRoot":"","sources":["../../../../../packages/cli/src/arg/ArgumentBuilder.ts"],"names":[],"mappings":";;;AAAA,+DAAsD;AACtD,qEAAiE;AACjE,qDAAiD;AACjD,2EAAuE;AAEvE,uCAAkD;AAElD;;GAEG;AACH,MAAa,eAAe;IAKL;IAJZ,CAAC,CAAU;IACX,KAAK,CAAQ;IACtB,gBAAgB,CAA2D;IAE3E,YAAqB,GAAmB,EAAE,IAAY;QAAjC,QAAG,GAAH,GAAG,CAAgB;QACtC,IAAI,CAAC,CAAC,GAAG,IAAI,wBAAQ,CAAC,IAAI,CAAC,CAAA;QAC3B,IAAI,CAAC,KAAK,GAAG,GAAG,CAAC,IAAI,CAAC,aAAa,CAAC,MAAM,CAAA;QAC1C,GAAG,CAAC,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,CAAA;QACvC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IACtC,CAAC;IAED,IAAI,aAAa;QACf,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,MAAM,GAAG,CAAC,CAAA;IAC3D,CAAC;IAED,IAAI,SAAS;QACX,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,SAAS,CAAA;IAC3D,CAAC;IAED,WAAW,CAAC,MAAc;QACxB,IAAI,CAAC,CAAC,CAAC,WAAW,GAAG,MAAM,CAAA;QAC3B,OAAO,IAAI,CAAA;IACb,CAAC;IAED,OAAO,CAAC,KAAc,EAAE,WAAoB;QAC1C,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,WAAW,CAAC,CAAA;QAClC,OAAO,IAAI,CAAA;IACb,CAAC;IAED,OAAO,CAAC,MAAyB;QAC/B,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;QACtB,OAAO,IAAI,CAAA;IACb,CAAC;IAED,IAAI,MAAM;QACR,OAAO,IAAI,+CAAsB,CAAC,IAAI,CAAC,CAAA;IACzC,CAAC;IAED,IAAI,SAAS;QACX,OAAO,IAAI,qDAAyB,CAAC,IAAI,CAAC,CAAA;IAC5C,CAAC;IAED,IAAI,GAAG;QACL,OAAO,IAAA,0BAAmB,EAAC,IAAI,EAAE,KAAK,EAAE,IAAI,+BAAc,CAAC,IAAI,CAAC,CAAC,CAAA;IACnE,CAAC;IAED;;OAEG;IACH,iBAAiB,CAAC,OAAiE;QACjF,IAAI,CAAC,gBAAgB,GAAG,OAAO,CAAA;QAC/B,OAAO,IAAI,CAAA;IACb,CAAC;CACF;AAtDD,0CAsDC"}
|
|
@@ -10,6 +10,7 @@ const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
|
10
10
|
const is_async_function_1 = __importDefault(require("is-async-function"));
|
|
11
11
|
const os_1 = __importDefault(require("os"));
|
|
12
12
|
const path_1 = __importDefault(require("path"));
|
|
13
|
+
const prompts_1 = __importDefault(require("prompts"));
|
|
13
14
|
const ArgumentBuilder_1 = require("../arg/ArgumentBuilder");
|
|
14
15
|
const util_1 = require("@bemoje/util");
|
|
15
16
|
const util_2 = require("@bemoje/util");
|
|
@@ -49,12 +50,12 @@ class CommandBuilder {
|
|
|
49
50
|
constructor(name, callback, parent, isNative = false) {
|
|
50
51
|
this.meta.isNative = isNative;
|
|
51
52
|
this.$ = new extra_typings_1.Command(name);
|
|
53
|
+
exports.commanderBackRefs.set(this.$, this);
|
|
52
54
|
if (parent) {
|
|
53
55
|
this.parent = parent;
|
|
54
56
|
this.parent.meta.subcommands.push(this);
|
|
55
57
|
this.parent.$.addCommand(this.$);
|
|
56
58
|
}
|
|
57
|
-
exports.commanderBackRefs.set(this.$, this);
|
|
58
59
|
this.initializeHelp();
|
|
59
60
|
if (callback)
|
|
60
61
|
callback.call(this, this);
|
|
@@ -91,10 +92,18 @@ class CommandBuilder {
|
|
|
91
92
|
this.presetsEnabled();
|
|
92
93
|
}
|
|
93
94
|
deleteDataFile() {
|
|
94
|
-
const filepath = this.
|
|
95
|
+
const filepath = this.jsonFilepath;
|
|
95
96
|
if (fs_extra_1.default.existsSync(filepath))
|
|
96
97
|
(0, util_13.removeFile)(filepath);
|
|
97
98
|
}
|
|
99
|
+
/**
|
|
100
|
+
* Set the program version to `str`.
|
|
101
|
+
*
|
|
102
|
+
* This method auto-registers the "-V, --version" flag
|
|
103
|
+
* which will print the version number when passed.
|
|
104
|
+
*
|
|
105
|
+
* You can optionally supply the flags and description to override the defaults.
|
|
106
|
+
*/
|
|
98
107
|
version(string) {
|
|
99
108
|
this.$.version(string);
|
|
100
109
|
const opt = this.options.find((o) => o.attributeName() === 'version');
|
|
@@ -102,6 +111,11 @@ class CommandBuilder {
|
|
|
102
111
|
this.meta.globalOptions.push(opt);
|
|
103
112
|
return this;
|
|
104
113
|
}
|
|
114
|
+
/**
|
|
115
|
+
* Set the description. If more than one sentence or string is given,
|
|
116
|
+
* then the first will be used as summary and the whole text as description.
|
|
117
|
+
* @param lines - description lines
|
|
118
|
+
*/
|
|
105
119
|
description(...lines) {
|
|
106
120
|
const description = lines.join('\n');
|
|
107
121
|
const summary = description.split(/(\. ?|\n|$)/)[0];
|
|
@@ -109,16 +123,32 @@ class CommandBuilder {
|
|
|
109
123
|
this.$.description(description);
|
|
110
124
|
return this;
|
|
111
125
|
}
|
|
126
|
+
/**
|
|
127
|
+
* Set an alias for the command.
|
|
128
|
+
* You may call more than once to add multiple aliases.
|
|
129
|
+
* Only the first alias is shown in the auto-generated help.
|
|
130
|
+
*/
|
|
112
131
|
alias(alias) {
|
|
113
132
|
this.assertCommandNameNotReserved(alias);
|
|
114
133
|
this.$.alias(alias);
|
|
115
134
|
return this;
|
|
116
135
|
}
|
|
136
|
+
/**
|
|
137
|
+
* Set aliases for the command. This overwrites all previously set aliases.
|
|
138
|
+
* Only the first alias is shown in the auto-generated help.
|
|
139
|
+
*/
|
|
117
140
|
aliases(...aliases) {
|
|
118
141
|
aliases.forEach((alias) => this.assertCommandNameNotReserved(alias));
|
|
119
142
|
this.$.aliases(aliases);
|
|
120
143
|
return this;
|
|
121
144
|
}
|
|
145
|
+
/**
|
|
146
|
+
* Set the command usage.
|
|
147
|
+
*/
|
|
148
|
+
usage(str) {
|
|
149
|
+
this.$.usage(str);
|
|
150
|
+
return this;
|
|
151
|
+
}
|
|
122
152
|
enableBuiltinOptions(options) {
|
|
123
153
|
if (!options || options.debug)
|
|
124
154
|
this.globalOption('-D, --debug', 'Output debugging information.');
|
|
@@ -139,6 +169,10 @@ class CommandBuilder {
|
|
|
139
169
|
else if (typeof cb === 'string') {
|
|
140
170
|
ins.description(cb);
|
|
141
171
|
}
|
|
172
|
+
if (ins.$.variadic && !ins.hasParser && !ins.hasValidators) {
|
|
173
|
+
ins.parser.string();
|
|
174
|
+
ins.validator.isStringArray();
|
|
175
|
+
}
|
|
142
176
|
return this;
|
|
143
177
|
}
|
|
144
178
|
option(flags, cb) {
|
|
@@ -152,6 +186,10 @@ class CommandBuilder {
|
|
|
152
186
|
else if (typeof cb === 'string') {
|
|
153
187
|
ins.description(cb);
|
|
154
188
|
}
|
|
189
|
+
if (ins.$.variadic && !ins.hasParser && !ins.hasValidators) {
|
|
190
|
+
ins.parser.string();
|
|
191
|
+
ins.validator.isStringArray();
|
|
192
|
+
}
|
|
155
193
|
return this;
|
|
156
194
|
}
|
|
157
195
|
globalOption(flags, cb) {
|
|
@@ -168,14 +206,27 @@ class CommandBuilder {
|
|
|
168
206
|
this.meta.hiddenGlobalOptions.add(opt);
|
|
169
207
|
});
|
|
170
208
|
}
|
|
209
|
+
/**
|
|
210
|
+
* Create a subcommand.
|
|
211
|
+
* @param flags - command name and arguments, args are `<required>` or `[optional]` and last may also be `variadic...`
|
|
212
|
+
* @param description - describe the command
|
|
213
|
+
*/
|
|
171
214
|
command(name, cb) {
|
|
172
215
|
new CommandBuilder(name, cb, this);
|
|
173
216
|
return this;
|
|
174
217
|
}
|
|
218
|
+
/**
|
|
219
|
+
* Create a native subcommand.
|
|
220
|
+
* @param flags - command name and arguments, args are `<required>` or `[optional]` and last may also be `variadic...`
|
|
221
|
+
* @param description - describe the command
|
|
222
|
+
*/
|
|
175
223
|
nativeCommand(name, cb) {
|
|
176
224
|
new CommandBuilder(name, cb, this, true);
|
|
177
225
|
return this;
|
|
178
226
|
}
|
|
227
|
+
/**
|
|
228
|
+
* Register callback function for the command to execute when invoked.
|
|
229
|
+
*/
|
|
179
230
|
action(fn) {
|
|
180
231
|
const isAsync = (0, is_async_function_1.default)(fn) || /^\(.+\) ?=> ?tslib_1\.__awaiter\(/.test(fn.toString().trim());
|
|
181
232
|
this.meta.isActionAsync = isAsync;
|
|
@@ -183,6 +234,16 @@ class CommandBuilder {
|
|
|
183
234
|
this.initializeActionWrapper(isAsync);
|
|
184
235
|
return this;
|
|
185
236
|
}
|
|
237
|
+
usageExamples(...examples) {
|
|
238
|
+
const table = examples.map(({ command, description }) => {
|
|
239
|
+
if (command.length + (description?.length || 0) > 100) {
|
|
240
|
+
this.throwCommanderError(`Usage example description too long: ${command}`);
|
|
241
|
+
}
|
|
242
|
+
return [command, description ?? ''];
|
|
243
|
+
});
|
|
244
|
+
this.description(this.$.description() + '\n\n' + 'Usage Examples:\n' + (0, util_5.formatTableForTerminal)(table));
|
|
245
|
+
return this;
|
|
246
|
+
}
|
|
186
247
|
errorHandler(fn) {
|
|
187
248
|
Object.defineProperty(this.meta, 'errorHandler', { value: fn, configurable: true });
|
|
188
249
|
return this;
|
|
@@ -220,14 +281,49 @@ class CommandBuilder {
|
|
|
220
281
|
this.features.autoAssignSubCommandAliases(boolean);
|
|
221
282
|
return this;
|
|
222
283
|
}
|
|
284
|
+
/**
|
|
285
|
+
* Allow excess command-arguments on the command line. Pass false to make excess arguments an error.
|
|
286
|
+
*
|
|
287
|
+
* @returns `this` command for chaining
|
|
288
|
+
*/
|
|
223
289
|
allowExcessArguments(bool = true) {
|
|
224
290
|
this.$.allowExcessArguments(bool);
|
|
225
291
|
return this;
|
|
226
292
|
}
|
|
293
|
+
/**
|
|
294
|
+
* Allow unknown options on the command line.
|
|
295
|
+
*
|
|
296
|
+
* @returns `this` command for chaining
|
|
297
|
+
*/
|
|
227
298
|
allowUnknownOption(bool = true) {
|
|
228
299
|
this.$.allowUnknownOption(bool);
|
|
229
300
|
return this;
|
|
230
301
|
}
|
|
302
|
+
/**
|
|
303
|
+
* Enable positional options. Positional means global options are specified before subcommands which lets
|
|
304
|
+
* subcommands reuse the same option names, and also enables subcommands to turn on passThroughOptions.
|
|
305
|
+
*
|
|
306
|
+
* The default behaviour is non-positional and global options may appear anywhere on the command line.
|
|
307
|
+
*
|
|
308
|
+
* @returns `this` command for chaining
|
|
309
|
+
*/
|
|
310
|
+
enablePositionalOptions(positional) {
|
|
311
|
+
this.$.enablePositionalOptions(positional);
|
|
312
|
+
return this;
|
|
313
|
+
}
|
|
314
|
+
/**
|
|
315
|
+
* Pass through options that come after command-arguments rather than treat them as command-options,
|
|
316
|
+
* so actual command-options come before command-arguments. Turning this on for a subcommand requires
|
|
317
|
+
* positional options to have been enabled on the program (parent commands).
|
|
318
|
+
*
|
|
319
|
+
* The default behaviour is non-positional and options may appear before or after command-arguments.
|
|
320
|
+
*
|
|
321
|
+
* @returns `this` command for chaining
|
|
322
|
+
*/
|
|
323
|
+
passThroughOptions(passThrough) {
|
|
324
|
+
this.$.passThroughOptions(passThrough);
|
|
325
|
+
return this;
|
|
326
|
+
}
|
|
231
327
|
/**
|
|
232
328
|
* Register callback to use as replacement for calling process.exit.
|
|
233
329
|
*/
|
|
@@ -235,13 +331,6 @@ class CommandBuilder {
|
|
|
235
331
|
this.$.exitOverride(callback);
|
|
236
332
|
return this;
|
|
237
333
|
}
|
|
238
|
-
throwInsteadOfProcessExit() {
|
|
239
|
-
const onErr = (err) => {
|
|
240
|
-
throw err;
|
|
241
|
-
};
|
|
242
|
-
this.exitOverride(onErr);
|
|
243
|
-
this.errorHandler(onErr);
|
|
244
|
-
}
|
|
245
334
|
/**
|
|
246
335
|
* Add hook for life cycle event.
|
|
247
336
|
*/
|
|
@@ -271,6 +360,19 @@ class CommandBuilder {
|
|
|
271
360
|
this.$.showSuggestionAfterError(displaySuggestion);
|
|
272
361
|
return this;
|
|
273
362
|
}
|
|
363
|
+
/**
|
|
364
|
+
* Override default decision whether to add implicit help command.
|
|
365
|
+
* @example ```
|
|
366
|
+
* addHelpCommand() // force on
|
|
367
|
+
* addHelpCommand(false); // force off
|
|
368
|
+
* addHelpCommand('help [cmd]', 'display help for [cmd]'); // force on with custom details
|
|
369
|
+
* ```
|
|
370
|
+
* @returns `this` command for chaining
|
|
371
|
+
*/
|
|
372
|
+
addHelpCommand(enableOrNameAndArgs, description) {
|
|
373
|
+
this.$.addHelpCommand(enableOrNameAndArgs, description);
|
|
374
|
+
return this;
|
|
375
|
+
}
|
|
274
376
|
/**
|
|
275
377
|
* Add additional text to be displayed with the built-in help.
|
|
276
378
|
*
|
|
@@ -359,7 +461,7 @@ class CommandBuilder {
|
|
|
359
461
|
* Output help information for this command.
|
|
360
462
|
*/
|
|
361
463
|
outputHelp() {
|
|
362
|
-
console.log(this.
|
|
464
|
+
console.log(this.getHelpInformation());
|
|
363
465
|
}
|
|
364
466
|
/**
|
|
365
467
|
* Display error message and exit (or call exitOverride).
|
|
@@ -373,7 +475,7 @@ class CommandBuilder {
|
|
|
373
475
|
if (!arg)
|
|
374
476
|
return arg;
|
|
375
477
|
const parse = this.meta.argParsers[i > last ? last : i];
|
|
376
|
-
return parse ? (Array.isArray(arg) ? arg.map(parse) : parse(arg)) : arg;
|
|
478
|
+
return parse ? (Array.isArray(arg) ? arg.map((a) => parse(a)) : parse(arg)) : arg;
|
|
377
479
|
});
|
|
378
480
|
}
|
|
379
481
|
/**
|
|
@@ -382,7 +484,7 @@ class CommandBuilder {
|
|
|
382
484
|
parseOptions(opts) {
|
|
383
485
|
for (const [key, value] of Object.entries(opts)) {
|
|
384
486
|
const parse = this.meta.optParsers[key];
|
|
385
|
-
opts[key] = parse ? (Array.isArray(value) ? value.map(parse) : parse(value)) : value;
|
|
487
|
+
opts[key] = parse ? (Array.isArray(value) ? value.map((o) => parse(o)) : parse(value)) : value;
|
|
386
488
|
}
|
|
387
489
|
return opts;
|
|
388
490
|
}
|
|
@@ -430,6 +532,13 @@ class CommandBuilder {
|
|
|
430
532
|
(0, util_4.ensureThat)(options, util_7.isObject);
|
|
431
533
|
this.assertValidOptions(options);
|
|
432
534
|
}
|
|
535
|
+
throwRatherThanExitProcess() {
|
|
536
|
+
const throwError = (error) => {
|
|
537
|
+
throw error;
|
|
538
|
+
};
|
|
539
|
+
this.errorHandler(throwError);
|
|
540
|
+
this.exitOverride(throwError);
|
|
541
|
+
}
|
|
433
542
|
get name() {
|
|
434
543
|
return this.$.name();
|
|
435
544
|
}
|
|
@@ -464,7 +573,7 @@ class CommandBuilder {
|
|
|
464
573
|
return false;
|
|
465
574
|
return (0, util_2.arrLast)(this.arguments).variadic;
|
|
466
575
|
}
|
|
467
|
-
get
|
|
576
|
+
get jsonFilepath() {
|
|
468
577
|
return path_1.default.join(CommandBuilder.dataDirectory, this.root.name + '.json');
|
|
469
578
|
}
|
|
470
579
|
/**
|
|
@@ -578,19 +687,55 @@ class CommandBuilder {
|
|
|
578
687
|
getSiblings() {
|
|
579
688
|
return [...this.getSiblingsIterator()];
|
|
580
689
|
}
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
}
|
|
586
|
-
this.throwCommanderError('No non-native parent found');
|
|
587
|
-
}
|
|
588
|
-
getRenderedHelp() {
|
|
690
|
+
/**
|
|
691
|
+
* Render the help string for the command.
|
|
692
|
+
*/
|
|
693
|
+
getHelpInformation() {
|
|
589
694
|
return this.$.helpInformation();
|
|
590
695
|
}
|
|
591
|
-
|
|
696
|
+
getOptsWithGlobals() {
|
|
592
697
|
return this.parseOptions(this.$.optsWithGlobals());
|
|
593
698
|
}
|
|
699
|
+
/**
|
|
700
|
+
* Parse `argv`, setting options and invoking commands when defined.
|
|
701
|
+
*
|
|
702
|
+
* The default expectation is that the arguments are from node and have the application as argv[0]
|
|
703
|
+
* and the script being run in argv[1], with user parameters after that.
|
|
704
|
+
*
|
|
705
|
+
* @example
|
|
706
|
+
* ```
|
|
707
|
+
* program.parse(process.argv);
|
|
708
|
+
* program.parse(); // implicitly use process.argv and auto-detect node vs electron conventions
|
|
709
|
+
* program.parse(my-args, { from: 'user' }); // just user supplied arguments, nothing special about argv[0]
|
|
710
|
+
* ```
|
|
711
|
+
*
|
|
712
|
+
* @returns `this` command for chaining
|
|
713
|
+
*/
|
|
714
|
+
parse(argv, options) {
|
|
715
|
+
this.$.parse(argv, options);
|
|
716
|
+
return this;
|
|
717
|
+
}
|
|
718
|
+
/**
|
|
719
|
+
* Parse `argv`, setting options and invoking commands when defined.
|
|
720
|
+
*
|
|
721
|
+
* Use parseAsync instead of parse if any of your action handlers are async. Returns a Promise.
|
|
722
|
+
*
|
|
723
|
+
* The default expectation is that the arguments are from node and have the application as argv[0]
|
|
724
|
+
* and the script being run in argv[1], with user parameters after that.
|
|
725
|
+
*
|
|
726
|
+
* @example
|
|
727
|
+
* ```
|
|
728
|
+
* program.parseAsync(process.argv);
|
|
729
|
+
* program.parseAsync(); // implicitly use process.argv and auto-detect node vs electron conventions
|
|
730
|
+
* program.parseAsync(my-args, { from: 'user' }); // just user supplied arguments, nothing special about argv[0]
|
|
731
|
+
* ```
|
|
732
|
+
*
|
|
733
|
+
* @returns Promise
|
|
734
|
+
*/
|
|
735
|
+
async parseAsync(argv, options) {
|
|
736
|
+
await this.$.parseAsync(argv, options);
|
|
737
|
+
return this;
|
|
738
|
+
}
|
|
594
739
|
getParsedValidArgsOptsWithPresets() {
|
|
595
740
|
const [presetArgs, presetOpts, presetOrder] = this.getPresetArgsAndOpts();
|
|
596
741
|
const args = this.getParsedValidArgsWithPresets(presetArgs);
|
|
@@ -605,9 +750,9 @@ class CommandBuilder {
|
|
|
605
750
|
return this.padArgsWithUndefinedUntilExpectedLength(result);
|
|
606
751
|
}
|
|
607
752
|
getParsedValidOptsWithPresets(presetOpts) {
|
|
608
|
-
const parsed = this.
|
|
753
|
+
const parsed = this.getOptsWithGlobals();
|
|
609
754
|
const opts = presetOpts.length ? (0, util_11.objAssign)({}, ...presetOpts, parsed) : parsed;
|
|
610
|
-
this.
|
|
755
|
+
this.hideOptionsWithDefaultOrNoValueOrArePresets(opts);
|
|
611
756
|
this.assertValidOptions(opts);
|
|
612
757
|
return opts;
|
|
613
758
|
}
|
|
@@ -643,10 +788,11 @@ class CommandBuilder {
|
|
|
643
788
|
});
|
|
644
789
|
}
|
|
645
790
|
}
|
|
646
|
-
|
|
647
|
-
const
|
|
791
|
+
hideOptionsWithDefaultOrNoValueOrArePresets(opts) {
|
|
792
|
+
const allOpts = this.getOwnAndGlobalOptions();
|
|
793
|
+
const optMap = Object.fromEntries(allOpts.map((o) => [o.attributeName(), o]));
|
|
648
794
|
for (const [key, value] of Object.entries(opts)) {
|
|
649
|
-
if (!
|
|
795
|
+
if (value == null || !optMap[key] || optMap[key].defaultValue === value) {
|
|
650
796
|
(0, util_14.setNonEnumerable)(opts, key);
|
|
651
797
|
}
|
|
652
798
|
}
|
|
@@ -691,7 +837,7 @@ class CommandBuilder {
|
|
|
691
837
|
return;
|
|
692
838
|
}
|
|
693
839
|
this.nativeCommand('util', (u) => {
|
|
694
|
-
const cmd = u.
|
|
840
|
+
const cmd = u.parent;
|
|
695
841
|
u.alias('u');
|
|
696
842
|
u.description('Utility commands.');
|
|
697
843
|
if (cmd.features.isConfigEnabled) {
|
|
@@ -709,7 +855,7 @@ class CommandBuilder {
|
|
|
709
855
|
function createUtilFilepathCommand(f) {
|
|
710
856
|
f.alias('f');
|
|
711
857
|
f.description('Print filepath to JSON file containing user data, eg. config and presets.');
|
|
712
|
-
f.action(async () => console.log(cmd.
|
|
858
|
+
f.action(async () => console.log(cmd.jsonFilepath));
|
|
713
859
|
}
|
|
714
860
|
function createUtilListCommand(l) {
|
|
715
861
|
l.alias('l');
|
|
@@ -989,6 +1135,25 @@ class CommandBuilder {
|
|
|
989
1135
|
}
|
|
990
1136
|
}
|
|
991
1137
|
}
|
|
1138
|
+
async getUserConfirmations(args) {
|
|
1139
|
+
for (let i = 0; i < args.length; i++) {
|
|
1140
|
+
const arg = args[i];
|
|
1141
|
+
const argb = this.meta.argBuilders[i];
|
|
1142
|
+
if (!argb || !argb.userConfirmation)
|
|
1143
|
+
continue;
|
|
1144
|
+
const { predicate, message } = argb.userConfirmation;
|
|
1145
|
+
if (predicate(arg)) {
|
|
1146
|
+
const result = await (0, prompts_1.default)({
|
|
1147
|
+
type: 'confirm',
|
|
1148
|
+
name: 'isConfirmed',
|
|
1149
|
+
message,
|
|
1150
|
+
initial: true,
|
|
1151
|
+
});
|
|
1152
|
+
if (!result.isConfirmed)
|
|
1153
|
+
this.outputError('Aborted.');
|
|
1154
|
+
}
|
|
1155
|
+
}
|
|
1156
|
+
}
|
|
992
1157
|
initializeActionWrapper(isAsync = false) {
|
|
993
1158
|
if (isAsync) {
|
|
994
1159
|
this.$.action(async () => {
|
|
@@ -997,7 +1162,8 @@ class CommandBuilder {
|
|
|
997
1162
|
const [args, opts] = this.getParsedValidArgsOptsWithPresets();
|
|
998
1163
|
if (opts['help'])
|
|
999
1164
|
return this.outputHelp();
|
|
1000
|
-
|
|
1165
|
+
await this.getUserConfirmations(args);
|
|
1166
|
+
const optswg = this.$.optsWithGlobals();
|
|
1001
1167
|
await this.meta.actionHandler.call(this, ...args, opts, this);
|
|
1002
1168
|
}
|
|
1003
1169
|
catch (error) {
|
|
@@ -1043,46 +1209,6 @@ class CommandBuilder {
|
|
|
1043
1209
|
this.throwCommanderError(`Name '${name}' is reserved and is not available as name or alias.`);
|
|
1044
1210
|
}
|
|
1045
1211
|
}
|
|
1046
|
-
/**
|
|
1047
|
-
* Parse `argv`, setting options and invoking commands when defined.
|
|
1048
|
-
*
|
|
1049
|
-
* The default expectation is that the arguments are from node and have the application as argv[0]
|
|
1050
|
-
* and the script being run in argv[1], with user parameters after that.
|
|
1051
|
-
*
|
|
1052
|
-
* @example
|
|
1053
|
-
* ```
|
|
1054
|
-
* program.parse(process.argv);
|
|
1055
|
-
* program.parse(); // implicitly use process.argv and auto-detect node vs electron conventions
|
|
1056
|
-
* program.parse(my-args, { from: 'user' }); // just user supplied arguments, nothing special about argv[0]
|
|
1057
|
-
* ```
|
|
1058
|
-
*
|
|
1059
|
-
* @returns `this` command for chaining
|
|
1060
|
-
*/
|
|
1061
|
-
parse(argv, options) {
|
|
1062
|
-
this.$.parse(argv, options);
|
|
1063
|
-
return this;
|
|
1064
|
-
}
|
|
1065
|
-
/**
|
|
1066
|
-
* Parse `argv`, setting options and invoking commands when defined.
|
|
1067
|
-
*
|
|
1068
|
-
* Use parseAsync instead of parse if any of your action handlers are async. Returns a Promise.
|
|
1069
|
-
*
|
|
1070
|
-
* The default expectation is that the arguments are from node and have the application as argv[0]
|
|
1071
|
-
* and the script being run in argv[1], with user parameters after that.
|
|
1072
|
-
*
|
|
1073
|
-
* @example
|
|
1074
|
-
* ```
|
|
1075
|
-
* program.parseAsync(process.argv);
|
|
1076
|
-
* program.parseAsync(); // implicitly use process.argv and auto-detect node vs electron conventions
|
|
1077
|
-
* program.parseAsync(my-args, { from: 'user' }); // just user supplied arguments, nothing special about argv[0]
|
|
1078
|
-
* ```
|
|
1079
|
-
*
|
|
1080
|
-
* @returns Promise
|
|
1081
|
-
*/
|
|
1082
|
-
async parseAsync(argv, options) {
|
|
1083
|
-
await this.$.parseAsync(argv, options);
|
|
1084
|
-
return this;
|
|
1085
|
-
}
|
|
1086
1212
|
}
|
|
1087
1213
|
exports.CommandBuilder = CommandBuilder;
|
|
1088
1214
|
exports.commanderBackRefs = new WeakMap();
|