@bemoje/cli 0.0.11 → 0.0.12
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 +191 -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 +191 -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,11 @@ class CommandBuilder {
|
|
|
183
234
|
this.initializeActionWrapper(isAsync);
|
|
184
235
|
return this;
|
|
185
236
|
}
|
|
237
|
+
usageExamples(...examples) {
|
|
238
|
+
const table = examples.map(({ command, description }) => [command, description ?? '']);
|
|
239
|
+
this.addHelpText('after', 'Usage Examples:\n' + (0, util_5.formatTableForTerminal)(table, ['command', 'description']));
|
|
240
|
+
return this;
|
|
241
|
+
}
|
|
186
242
|
errorHandler(fn) {
|
|
187
243
|
Object.defineProperty(this.meta, 'errorHandler', { value: fn, configurable: true });
|
|
188
244
|
return this;
|
|
@@ -220,14 +276,49 @@ class CommandBuilder {
|
|
|
220
276
|
this.features.autoAssignSubCommandAliases(boolean);
|
|
221
277
|
return this;
|
|
222
278
|
}
|
|
279
|
+
/**
|
|
280
|
+
* Allow excess command-arguments on the command line. Pass false to make excess arguments an error.
|
|
281
|
+
*
|
|
282
|
+
* @returns `this` command for chaining
|
|
283
|
+
*/
|
|
223
284
|
allowExcessArguments(bool = true) {
|
|
224
285
|
this.$.allowExcessArguments(bool);
|
|
225
286
|
return this;
|
|
226
287
|
}
|
|
288
|
+
/**
|
|
289
|
+
* Allow unknown options on the command line.
|
|
290
|
+
*
|
|
291
|
+
* @returns `this` command for chaining
|
|
292
|
+
*/
|
|
227
293
|
allowUnknownOption(bool = true) {
|
|
228
294
|
this.$.allowUnknownOption(bool);
|
|
229
295
|
return this;
|
|
230
296
|
}
|
|
297
|
+
/**
|
|
298
|
+
* Enable positional options. Positional means global options are specified before subcommands which lets
|
|
299
|
+
* subcommands reuse the same option names, and also enables subcommands to turn on passThroughOptions.
|
|
300
|
+
*
|
|
301
|
+
* The default behaviour is non-positional and global options may appear anywhere on the command line.
|
|
302
|
+
*
|
|
303
|
+
* @returns `this` command for chaining
|
|
304
|
+
*/
|
|
305
|
+
enablePositionalOptions(positional) {
|
|
306
|
+
this.$.enablePositionalOptions(positional);
|
|
307
|
+
return this;
|
|
308
|
+
}
|
|
309
|
+
/**
|
|
310
|
+
* Pass through options that come after command-arguments rather than treat them as command-options,
|
|
311
|
+
* so actual command-options come before command-arguments. Turning this on for a subcommand requires
|
|
312
|
+
* positional options to have been enabled on the program (parent commands).
|
|
313
|
+
*
|
|
314
|
+
* The default behaviour is non-positional and options may appear before or after command-arguments.
|
|
315
|
+
*
|
|
316
|
+
* @returns `this` command for chaining
|
|
317
|
+
*/
|
|
318
|
+
passThroughOptions(passThrough) {
|
|
319
|
+
this.$.passThroughOptions(passThrough);
|
|
320
|
+
return this;
|
|
321
|
+
}
|
|
231
322
|
/**
|
|
232
323
|
* Register callback to use as replacement for calling process.exit.
|
|
233
324
|
*/
|
|
@@ -235,13 +326,6 @@ class CommandBuilder {
|
|
|
235
326
|
this.$.exitOverride(callback);
|
|
236
327
|
return this;
|
|
237
328
|
}
|
|
238
|
-
throwInsteadOfProcessExit() {
|
|
239
|
-
const onErr = (err) => {
|
|
240
|
-
throw err;
|
|
241
|
-
};
|
|
242
|
-
this.exitOverride(onErr);
|
|
243
|
-
this.errorHandler(onErr);
|
|
244
|
-
}
|
|
245
329
|
/**
|
|
246
330
|
* Add hook for life cycle event.
|
|
247
331
|
*/
|
|
@@ -271,6 +355,19 @@ class CommandBuilder {
|
|
|
271
355
|
this.$.showSuggestionAfterError(displaySuggestion);
|
|
272
356
|
return this;
|
|
273
357
|
}
|
|
358
|
+
/**
|
|
359
|
+
* Override default decision whether to add implicit help command.
|
|
360
|
+
* @example ```
|
|
361
|
+
* addHelpCommand() // force on
|
|
362
|
+
* addHelpCommand(false); // force off
|
|
363
|
+
* addHelpCommand('help [cmd]', 'display help for [cmd]'); // force on with custom details
|
|
364
|
+
* ```
|
|
365
|
+
* @returns `this` command for chaining
|
|
366
|
+
*/
|
|
367
|
+
addHelpCommand(enableOrNameAndArgs, description) {
|
|
368
|
+
this.$.addHelpCommand(enableOrNameAndArgs, description);
|
|
369
|
+
return this;
|
|
370
|
+
}
|
|
274
371
|
/**
|
|
275
372
|
* Add additional text to be displayed with the built-in help.
|
|
276
373
|
*
|
|
@@ -359,7 +456,7 @@ class CommandBuilder {
|
|
|
359
456
|
* Output help information for this command.
|
|
360
457
|
*/
|
|
361
458
|
outputHelp() {
|
|
362
|
-
console.log(this.
|
|
459
|
+
console.log(this.getHelpInformation());
|
|
363
460
|
}
|
|
364
461
|
/**
|
|
365
462
|
* Display error message and exit (or call exitOverride).
|
|
@@ -373,7 +470,7 @@ class CommandBuilder {
|
|
|
373
470
|
if (!arg)
|
|
374
471
|
return arg;
|
|
375
472
|
const parse = this.meta.argParsers[i > last ? last : i];
|
|
376
|
-
return parse ? (Array.isArray(arg) ? arg.map(parse) : parse(arg)) : arg;
|
|
473
|
+
return parse ? (Array.isArray(arg) ? arg.map((a) => parse(a)) : parse(arg)) : arg;
|
|
377
474
|
});
|
|
378
475
|
}
|
|
379
476
|
/**
|
|
@@ -382,7 +479,7 @@ class CommandBuilder {
|
|
|
382
479
|
parseOptions(opts) {
|
|
383
480
|
for (const [key, value] of Object.entries(opts)) {
|
|
384
481
|
const parse = this.meta.optParsers[key];
|
|
385
|
-
opts[key] = parse ? (Array.isArray(value) ? value.map(parse) : parse(value)) : value;
|
|
482
|
+
opts[key] = parse ? (Array.isArray(value) ? value.map((o) => parse(o)) : parse(value)) : value;
|
|
386
483
|
}
|
|
387
484
|
return opts;
|
|
388
485
|
}
|
|
@@ -430,6 +527,13 @@ class CommandBuilder {
|
|
|
430
527
|
(0, util_4.ensureThat)(options, util_7.isObject);
|
|
431
528
|
this.assertValidOptions(options);
|
|
432
529
|
}
|
|
530
|
+
throwRatherThanExitProcess() {
|
|
531
|
+
const throwError = (error) => {
|
|
532
|
+
throw error;
|
|
533
|
+
};
|
|
534
|
+
this.errorHandler(throwError);
|
|
535
|
+
this.exitOverride(throwError);
|
|
536
|
+
}
|
|
433
537
|
get name() {
|
|
434
538
|
return this.$.name();
|
|
435
539
|
}
|
|
@@ -464,7 +568,7 @@ class CommandBuilder {
|
|
|
464
568
|
return false;
|
|
465
569
|
return (0, util_2.arrLast)(this.arguments).variadic;
|
|
466
570
|
}
|
|
467
|
-
get
|
|
571
|
+
get jsonFilepath() {
|
|
468
572
|
return path_1.default.join(CommandBuilder.dataDirectory, this.root.name + '.json');
|
|
469
573
|
}
|
|
470
574
|
/**
|
|
@@ -578,19 +682,55 @@ class CommandBuilder {
|
|
|
578
682
|
getSiblings() {
|
|
579
683
|
return [...this.getSiblingsIterator()];
|
|
580
684
|
}
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
}
|
|
586
|
-
this.throwCommanderError('No non-native parent found');
|
|
587
|
-
}
|
|
588
|
-
getRenderedHelp() {
|
|
685
|
+
/**
|
|
686
|
+
* Render the help string for the command.
|
|
687
|
+
*/
|
|
688
|
+
getHelpInformation() {
|
|
589
689
|
return this.$.helpInformation();
|
|
590
690
|
}
|
|
591
|
-
|
|
691
|
+
getOptsWithGlobals() {
|
|
592
692
|
return this.parseOptions(this.$.optsWithGlobals());
|
|
593
693
|
}
|
|
694
|
+
/**
|
|
695
|
+
* Parse `argv`, setting options and invoking commands when defined.
|
|
696
|
+
*
|
|
697
|
+
* The default expectation is that the arguments are from node and have the application as argv[0]
|
|
698
|
+
* and the script being run in argv[1], with user parameters after that.
|
|
699
|
+
*
|
|
700
|
+
* @example
|
|
701
|
+
* ```
|
|
702
|
+
* program.parse(process.argv);
|
|
703
|
+
* program.parse(); // implicitly use process.argv and auto-detect node vs electron conventions
|
|
704
|
+
* program.parse(my-args, { from: 'user' }); // just user supplied arguments, nothing special about argv[0]
|
|
705
|
+
* ```
|
|
706
|
+
*
|
|
707
|
+
* @returns `this` command for chaining
|
|
708
|
+
*/
|
|
709
|
+
parse(argv, options) {
|
|
710
|
+
this.$.parse(argv, options);
|
|
711
|
+
return this;
|
|
712
|
+
}
|
|
713
|
+
/**
|
|
714
|
+
* Parse `argv`, setting options and invoking commands when defined.
|
|
715
|
+
*
|
|
716
|
+
* Use parseAsync instead of parse if any of your action handlers are async. Returns a Promise.
|
|
717
|
+
*
|
|
718
|
+
* The default expectation is that the arguments are from node and have the application as argv[0]
|
|
719
|
+
* and the script being run in argv[1], with user parameters after that.
|
|
720
|
+
*
|
|
721
|
+
* @example
|
|
722
|
+
* ```
|
|
723
|
+
* program.parseAsync(process.argv);
|
|
724
|
+
* program.parseAsync(); // implicitly use process.argv and auto-detect node vs electron conventions
|
|
725
|
+
* program.parseAsync(my-args, { from: 'user' }); // just user supplied arguments, nothing special about argv[0]
|
|
726
|
+
* ```
|
|
727
|
+
*
|
|
728
|
+
* @returns Promise
|
|
729
|
+
*/
|
|
730
|
+
async parseAsync(argv, options) {
|
|
731
|
+
await this.$.parseAsync(argv, options);
|
|
732
|
+
return this;
|
|
733
|
+
}
|
|
594
734
|
getParsedValidArgsOptsWithPresets() {
|
|
595
735
|
const [presetArgs, presetOpts, presetOrder] = this.getPresetArgsAndOpts();
|
|
596
736
|
const args = this.getParsedValidArgsWithPresets(presetArgs);
|
|
@@ -605,9 +745,9 @@ class CommandBuilder {
|
|
|
605
745
|
return this.padArgsWithUndefinedUntilExpectedLength(result);
|
|
606
746
|
}
|
|
607
747
|
getParsedValidOptsWithPresets(presetOpts) {
|
|
608
|
-
const parsed = this.
|
|
748
|
+
const parsed = this.getOptsWithGlobals();
|
|
609
749
|
const opts = presetOpts.length ? (0, util_11.objAssign)({}, ...presetOpts, parsed) : parsed;
|
|
610
|
-
this.
|
|
750
|
+
this.hideOptionsWithDefaultOrNoValueOrArePresets(opts);
|
|
611
751
|
this.assertValidOptions(opts);
|
|
612
752
|
return opts;
|
|
613
753
|
}
|
|
@@ -643,10 +783,11 @@ class CommandBuilder {
|
|
|
643
783
|
});
|
|
644
784
|
}
|
|
645
785
|
}
|
|
646
|
-
|
|
647
|
-
const
|
|
786
|
+
hideOptionsWithDefaultOrNoValueOrArePresets(opts) {
|
|
787
|
+
const allOpts = this.getOwnAndGlobalOptions();
|
|
788
|
+
const optMap = Object.fromEntries(allOpts.map((o) => [o.attributeName(), o]));
|
|
648
789
|
for (const [key, value] of Object.entries(opts)) {
|
|
649
|
-
if (!
|
|
790
|
+
if (value == null || !optMap[key] || optMap[key].defaultValue === value) {
|
|
650
791
|
(0, util_14.setNonEnumerable)(opts, key);
|
|
651
792
|
}
|
|
652
793
|
}
|
|
@@ -691,7 +832,7 @@ class CommandBuilder {
|
|
|
691
832
|
return;
|
|
692
833
|
}
|
|
693
834
|
this.nativeCommand('util', (u) => {
|
|
694
|
-
const cmd = u.
|
|
835
|
+
const cmd = u.parent;
|
|
695
836
|
u.alias('u');
|
|
696
837
|
u.description('Utility commands.');
|
|
697
838
|
if (cmd.features.isConfigEnabled) {
|
|
@@ -709,7 +850,7 @@ class CommandBuilder {
|
|
|
709
850
|
function createUtilFilepathCommand(f) {
|
|
710
851
|
f.alias('f');
|
|
711
852
|
f.description('Print filepath to JSON file containing user data, eg. config and presets.');
|
|
712
|
-
f.action(async () => console.log(cmd.
|
|
853
|
+
f.action(async () => console.log(cmd.jsonFilepath));
|
|
713
854
|
}
|
|
714
855
|
function createUtilListCommand(l) {
|
|
715
856
|
l.alias('l');
|
|
@@ -989,6 +1130,25 @@ class CommandBuilder {
|
|
|
989
1130
|
}
|
|
990
1131
|
}
|
|
991
1132
|
}
|
|
1133
|
+
async getUserConfirmations(args) {
|
|
1134
|
+
for (let i = 0; i < args.length; i++) {
|
|
1135
|
+
const arg = args[i];
|
|
1136
|
+
const argb = this.meta.argBuilders[i];
|
|
1137
|
+
if (!argb || !argb.userConfirmation)
|
|
1138
|
+
continue;
|
|
1139
|
+
const { predicate, message } = argb.userConfirmation;
|
|
1140
|
+
if (predicate(arg)) {
|
|
1141
|
+
const result = await (0, prompts_1.default)({
|
|
1142
|
+
type: 'confirm',
|
|
1143
|
+
name: 'isConfirmed',
|
|
1144
|
+
message,
|
|
1145
|
+
initial: true,
|
|
1146
|
+
});
|
|
1147
|
+
if (!result.isConfirmed)
|
|
1148
|
+
this.outputError('Aborted.');
|
|
1149
|
+
}
|
|
1150
|
+
}
|
|
1151
|
+
}
|
|
992
1152
|
initializeActionWrapper(isAsync = false) {
|
|
993
1153
|
if (isAsync) {
|
|
994
1154
|
this.$.action(async () => {
|
|
@@ -997,7 +1157,8 @@ class CommandBuilder {
|
|
|
997
1157
|
const [args, opts] = this.getParsedValidArgsOptsWithPresets();
|
|
998
1158
|
if (opts['help'])
|
|
999
1159
|
return this.outputHelp();
|
|
1000
|
-
|
|
1160
|
+
await this.getUserConfirmations(args);
|
|
1161
|
+
const optswg = this.$.optsWithGlobals();
|
|
1001
1162
|
await this.meta.actionHandler.call(this, ...args, opts, this);
|
|
1002
1163
|
}
|
|
1003
1164
|
catch (error) {
|
|
@@ -1043,46 +1204,6 @@ class CommandBuilder {
|
|
|
1043
1204
|
this.throwCommanderError(`Name '${name}' is reserved and is not available as name or alias.`);
|
|
1044
1205
|
}
|
|
1045
1206
|
}
|
|
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
1207
|
}
|
|
1087
1208
|
exports.CommandBuilder = CommandBuilder;
|
|
1088
1209
|
exports.commanderBackRefs = new WeakMap();
|