cli-forge 0.6.0 → 0.8.0
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/bin/cli.js +3 -1
- package/bin/cli.js.map +1 -1
- package/bin/commands/generate-documentation.d.ts +2 -2
- package/bin/commands/generate-documentation.js +42 -13
- package/bin/commands/generate-documentation.js.map +1 -1
- package/bin/commands/init.d.ts +2 -2
- package/bin/commands/init.js +103 -13
- package/bin/commands/init.js.map +1 -1
- package/package.json +2 -2
- package/src/index.d.ts +4 -1
- package/src/index.js +9 -4
- package/src/index.js.map +1 -1
- package/src/lib/cli-option-groups.d.ts +7 -0
- package/src/lib/cli-option-groups.js +62 -0
- package/src/lib/cli-option-groups.js.map +1 -0
- package/src/lib/composable-builder.d.ts +3 -0
- package/src/lib/composable-builder.js +7 -0
- package/src/lib/composable-builder.js.map +1 -0
- package/src/lib/documentation.d.ts +15 -21
- package/src/lib/documentation.js +34 -2
- package/src/lib/documentation.js.map +1 -1
- package/src/lib/format-help.d.ts +2 -0
- package/src/lib/format-help.js +114 -0
- package/src/lib/format-help.js.map +1 -0
- package/src/lib/interactive-shell.d.ts +2 -2
- package/src/lib/interactive-shell.js +4 -1
- package/src/lib/interactive-shell.js.map +1 -1
- package/src/lib/internal-cli.d.ts +122 -0
- package/src/lib/{cli-forge.js → internal-cli.js} +63 -111
- package/src/lib/internal-cli.js.map +1 -0
- package/src/lib/{cli-forge.d.ts → public-api.d.ts} +60 -114
- package/src/lib/public-api.js +15 -0
- package/src/lib/public-api.js.map +1 -0
- package/src/lib/test-harness.d.ts +1 -1
- package/src/lib/test-harness.js +5 -3
- package/src/lib/test-harness.js.map +1 -1
- package/src/lib/cli-forge.js.map +0 -1
package/src/lib/documentation.js
CHANGED
|
@@ -1,18 +1,48 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.generateDocumentation = generateDocumentation;
|
|
4
|
+
const parser_1 = require("@cli-forge/parser");
|
|
5
|
+
function normalizeOptionConfigForDocumentation(option, key) {
|
|
6
|
+
const { default: declaredDefault, ...rest } = option;
|
|
7
|
+
let resolvedDefault;
|
|
8
|
+
if (declaredDefault !== undefined) {
|
|
9
|
+
const [defaultValue, description] = (0, parser_1.readDefaultValue)(option);
|
|
10
|
+
resolvedDefault = description ?? defaultValue;
|
|
11
|
+
}
|
|
12
|
+
const result = { ...rest, key };
|
|
13
|
+
if (resolvedDefault !== undefined) {
|
|
14
|
+
result.default = resolvedDefault;
|
|
15
|
+
}
|
|
16
|
+
return result;
|
|
17
|
+
}
|
|
4
18
|
function generateDocumentation(cli, commandChain = []) {
|
|
5
19
|
// Ensure current command's options are built.
|
|
6
20
|
if (cli.configuration?.builder) {
|
|
21
|
+
// The cli instance here is typed a bit too well
|
|
22
|
+
// for the builder function, so we need to cast it to
|
|
23
|
+
// a more generic form.
|
|
7
24
|
cli.configuration.builder(cli);
|
|
8
25
|
}
|
|
9
26
|
const parser = cli.getParser();
|
|
10
|
-
const
|
|
27
|
+
const groupedOptions = cli.getGroupedOptions();
|
|
28
|
+
const options = Object.fromEntries(Object.entries(parser.configuredOptions)
|
|
29
|
+
.filter(([, c]) => !c.hidden)
|
|
30
|
+
.map(([k, v]) => [k, normalizeOptionConfigForDocumentation(v, k)]));
|
|
11
31
|
const positionals = parser.configuredPositionals;
|
|
12
32
|
for (const positional of positionals) {
|
|
13
33
|
delete options[positional.key];
|
|
14
34
|
}
|
|
15
|
-
const subcommands =
|
|
35
|
+
const subcommands = [];
|
|
36
|
+
for (const subcommand of Object.values(cli.getSubcommands())) {
|
|
37
|
+
if (subcommand.configuration?.hidden !== true) {
|
|
38
|
+
const clone = subcommand.clone();
|
|
39
|
+
if (clone.configuration) {
|
|
40
|
+
clone.configuration.epilogue ??= cli.configuration?.epilogue;
|
|
41
|
+
}
|
|
42
|
+
subcommands.push(generateDocumentation(clone, [...commandChain, cli.name]));
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
Object.values(cli.getSubcommands()).map((cmd) => generateDocumentation(cmd.clone(), [...commandChain, cli.name]));
|
|
16
46
|
return {
|
|
17
47
|
name: cli.name,
|
|
18
48
|
description: cli.configuration?.description,
|
|
@@ -25,7 +55,9 @@ function generateDocumentation(cli, commandChain = []) {
|
|
|
25
55
|
cli.name,
|
|
26
56
|
...positionals.map((p) => (p.required ? `<${p.key}>` : `[${p.key}]`)),
|
|
27
57
|
].join(' '),
|
|
58
|
+
epilogue: cli.configuration?.epilogue,
|
|
28
59
|
examples: cli.configuration?.examples ?? [],
|
|
60
|
+
groupedOptions,
|
|
29
61
|
options,
|
|
30
62
|
positionals,
|
|
31
63
|
subcommands,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"documentation.js","sourceRoot":"","sources":["../../../../../packages/cli-forge/src/lib/documentation.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"documentation.js","sourceRoot":"","sources":["../../../../../packages/cli-forge/src/lib/documentation.ts"],"names":[],"mappings":";;AA+CA,sDA2DC;AA1GD,8CAI2B;AAmB3B,SAAS,qCAAqC,CAC5C,MAAS,EACT,GAAW;IAEX,MAAM,EAAE,OAAO,EAAE,eAAe,EAAE,GAAG,IAAI,EAAE,GAAG,MAAM,CAAC;IACrD,IAAI,eAA2D,CAAC;IAChE,IAAI,eAAe,KAAK,SAAS,EAAE,CAAC;QAClC,MAAM,CAAC,YAAY,EAAE,WAAW,CAAC,GAAG,IAAA,yBAAgB,EAAC,MAAM,CAAC,CAAC;QAC7D,eAAe,GAAG,WAAW,IAAI,YAAY,CAAC;IAChD,CAAC;IACD,MAAM,MAAM,GAGR,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,CAAC;IACrB,IAAI,eAAe,KAAK,SAAS,EAAE,CAAC;QAClC,MAAM,CAAC,OAAO,GAAG,eAAe,CAAC;IACnC,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAMD,SAAgB,qBAAqB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ict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.formatHelp = formatHelp;
|
|
4
|
+
const parser_1 = require("@cli-forge/parser");
|
|
5
|
+
function formatHelp(parentCLI) {
|
|
6
|
+
const help = [];
|
|
7
|
+
let command = parentCLI;
|
|
8
|
+
let epilogue = parentCLI.configuration?.epilogue;
|
|
9
|
+
for (const key of parentCLI.commandChain) {
|
|
10
|
+
command = command.registeredCommands[key];
|
|
11
|
+
// Properties that are ineherited from the parent command should be copied over
|
|
12
|
+
if (command.configuration?.epilogue) {
|
|
13
|
+
epilogue = command.configuration.epilogue;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
help.push(`Usage: ${command.configuration?.usage
|
|
17
|
+
? command.configuration.usage
|
|
18
|
+
: [
|
|
19
|
+
parentCLI.name,
|
|
20
|
+
...parentCLI.commandChain,
|
|
21
|
+
...command.parser.configuredPositionals.map((p) => p.required ? `<${p.key}>` : `[${p.key}]`),
|
|
22
|
+
].join(' ')}`);
|
|
23
|
+
if (command.configuration?.description) {
|
|
24
|
+
help.push(command.configuration.description);
|
|
25
|
+
}
|
|
26
|
+
if (Object.keys(command.registeredCommands).length > 0) {
|
|
27
|
+
help.push('');
|
|
28
|
+
help.push('Commands:');
|
|
29
|
+
}
|
|
30
|
+
for (const key in command.registeredCommands) {
|
|
31
|
+
const subcommand = command.registeredCommands[key];
|
|
32
|
+
help.push(` ${key}${subcommand.configuration?.description
|
|
33
|
+
? ' - ' + subcommand.configuration.description
|
|
34
|
+
: ''}`);
|
|
35
|
+
}
|
|
36
|
+
const groupedOptions = parentCLI.getGroupedOptions();
|
|
37
|
+
const nonpositionalOptions = Object.values(command.parser.configuredOptions).filter((c) => !c.positional);
|
|
38
|
+
help.push(...getOptionBlock('Options', nonpositionalOptions));
|
|
39
|
+
for (const { label, keys } of groupedOptions) {
|
|
40
|
+
help.push(...getOptionBlock(label, keys));
|
|
41
|
+
}
|
|
42
|
+
if (command.configuration?.examples?.length) {
|
|
43
|
+
help.push('');
|
|
44
|
+
help.push('Examples:');
|
|
45
|
+
for (const example of command.configuration.examples) {
|
|
46
|
+
help.push(` \`${example}\``);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
if (Object.keys(command.registeredCommands).length > 0) {
|
|
50
|
+
help.push(' ');
|
|
51
|
+
help.push(`Run \`${[parentCLI.name, ...parentCLI.commandChain].join(' ')} [command] --help\` for more information on a command`);
|
|
52
|
+
}
|
|
53
|
+
if (epilogue) {
|
|
54
|
+
help.push('');
|
|
55
|
+
help.push(epilogue);
|
|
56
|
+
}
|
|
57
|
+
return help.join('\n');
|
|
58
|
+
}
|
|
59
|
+
function getOptionParts(option) {
|
|
60
|
+
const parts = [];
|
|
61
|
+
if (option.description) {
|
|
62
|
+
parts.push(option.description);
|
|
63
|
+
}
|
|
64
|
+
if ('choices' in option && option.choices) {
|
|
65
|
+
const choices = typeof option.choices === 'function' ? option.choices() : option.choices;
|
|
66
|
+
parts.push(`(${choices.join(', ')})`);
|
|
67
|
+
}
|
|
68
|
+
if (option.default) {
|
|
69
|
+
parts.push('[default: ' + formatDefaultValue((0, parser_1.readDefaultValue)(option)) + ']');
|
|
70
|
+
}
|
|
71
|
+
else if (option.required) {
|
|
72
|
+
parts.push('[required]');
|
|
73
|
+
}
|
|
74
|
+
if (option.deprecated) {
|
|
75
|
+
parts.push('[deprecated: ' + option.deprecated + ']');
|
|
76
|
+
}
|
|
77
|
+
return parts;
|
|
78
|
+
}
|
|
79
|
+
function formatDefaultValue([value, description]) {
|
|
80
|
+
if (description) {
|
|
81
|
+
return description;
|
|
82
|
+
}
|
|
83
|
+
return removeTrailingAndLeadingQuotes(JSON.stringify(value));
|
|
84
|
+
}
|
|
85
|
+
function removeTrailingAndLeadingQuotes(str) {
|
|
86
|
+
return str.replace(/^['"]/, '').replace(/['"]$/, '');
|
|
87
|
+
}
|
|
88
|
+
function getOptionBlock(label, options) {
|
|
89
|
+
const lines = [];
|
|
90
|
+
if (options.length > 0) {
|
|
91
|
+
lines.push('');
|
|
92
|
+
lines.push(label + ':');
|
|
93
|
+
}
|
|
94
|
+
const allParts = [];
|
|
95
|
+
for (const option of options) {
|
|
96
|
+
allParts.push([option.key, ...getOptionParts(option)]);
|
|
97
|
+
}
|
|
98
|
+
const paddingValues = [];
|
|
99
|
+
for (let i = 0; i < allParts.length; i++) {
|
|
100
|
+
for (let j = 0; j < allParts[i].length; j++) {
|
|
101
|
+
if (!paddingValues[j]) {
|
|
102
|
+
paddingValues[j] = 0;
|
|
103
|
+
}
|
|
104
|
+
paddingValues[j] = Math.max(paddingValues[j], allParts[i][j].length);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
for (const [key, ...parts] of allParts) {
|
|
108
|
+
lines.push(` --${key.padEnd(paddingValues[0])}${parts.length ? ' - ' : ''}${parts
|
|
109
|
+
.map((part, i) => part.padEnd(paddingValues[i + 1]))
|
|
110
|
+
.join(' ')}`);
|
|
111
|
+
}
|
|
112
|
+
return lines;
|
|
113
|
+
}
|
|
114
|
+
//# sourceMappingURL=format-help.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format-help.js","sourceRoot":"","sources":["../../../../../packages/cli-forge/src/lib/format-help.ts"],"names":[],"mappings":";;AAOA,gCA4EC;AAnFD,8CAI2B;AAG3B,SAAgB,UAAU,CAAC,SAA2B;IACpD,MAAM,IAAI,GAAa,EAAE,CAAC;IAC1B,IAAI,OAAO,GAAG,SAAS,CAAC;IACxB,IAAI,QAAQ,GAAG,SAAS,CAAC,aAAa,EAAE,QAAQ,CAAC;IACjD,KAAK,MAAM,GAAG,IAAI,SAAS,CAAC,YAAY,EAAE,CAAC;QACzC,OAAO,GAAG,OAAO,CAAC,kBAAkB,CAAC,GAAG,CAAqB,CAAC;QAE9D,+EAA+E;QAC/E,IAAI,OAAO,CAAC,aAAa,EAAE,QAAQ,EAAE,CAAC;YACpC,QAAQ,GAAG,OAAO,CAAC,aAAa,CAAC,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AC,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,GAAG,KAAK;aACpE,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;aACnD,IAAI,CAAC,GAAG,CAAC,EAAE,CACf,CAAC;IACJ,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { InternalCLI } from './cli
|
|
1
|
+
import { InternalCLI } from './internal-cli';
|
|
2
2
|
export interface InteractiveShellOptions {
|
|
3
3
|
prompt?: string;
|
|
4
4
|
prependArgs?: string[];
|
|
@@ -7,7 +7,7 @@ export declare let INTERACTIVE_SHELL: InteractiveShell | undefined;
|
|
|
7
7
|
export declare class InteractiveShell {
|
|
8
8
|
private readonly rl;
|
|
9
9
|
private listeners;
|
|
10
|
-
constructor(cli: InternalCLI
|
|
10
|
+
constructor(cli: InternalCLI<any>, opts?: InteractiveShellOptions);
|
|
11
11
|
registerLineListener(callback: (line: string) => Promise<void>): void;
|
|
12
12
|
close(): void;
|
|
13
13
|
}
|
|
@@ -28,6 +28,7 @@ class InteractiveShell {
|
|
|
28
28
|
if (exports.INTERACTIVE_SHELL) {
|
|
29
29
|
throw new Error('Only one interactive shell can be created at a time. Make sure the other instance is closed.');
|
|
30
30
|
}
|
|
31
|
+
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
31
32
|
exports.INTERACTIVE_SHELL = this;
|
|
32
33
|
const { prompt, prependArgs } = normalizeShellOptions(cli, opts);
|
|
33
34
|
this.rl = readline
|
|
@@ -58,7 +59,9 @@ class InteractiveShell {
|
|
|
58
59
|
try {
|
|
59
60
|
(0, child_process_1.execSync)(line, { stdio: 'inherit' });
|
|
60
61
|
}
|
|
61
|
-
catch {
|
|
62
|
+
catch {
|
|
63
|
+
// ignore
|
|
64
|
+
}
|
|
62
65
|
}
|
|
63
66
|
});
|
|
64
67
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interactive-shell.js","sourceRoot":"","sources":["../../../../../packages/cli-forge/src/lib/interactive-shell.ts"],"names":[],"mappings":";;;AAAA,qCAAqC;AACrC,mCAAuC;AAEvC,iDAAoD;AACpD,8CAA2C;AAS3C,SAAS,qBAAqB,CAC5B,GAAgB,EAChB,OAAiC;IAEjC,OAAO;QACL,MAAM,EACJ,OAAO,EAAE,MAAM;YACf,CAAC,GAAG,EAAE;gBACJ,MAAM,KAAK,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;gBACzB,IAAI,GAAG,CAAC,YAAY,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;oBAChC,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE,GAAG,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC;gBACjE,CAAC;qBAAM,CAAC;oBACN,KAAK,CAAC,IAAI,CAAC,GAAG,GAAG,CAAC,YAAY,CAAC,CAAC;gBAClC,CAAC;gBACD,OAAO,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC;YAChC,CAAC,CAAC,EAAE;QACN,WAAW,EAAE,OAAO,EAAE,WAAW,IAAI,EAAE;KACxC,CAAC;AACJ,CAAC;AAID,MAAa,gBAAgB;IACV,EAAE,CAAqB;IAChC,SAAS,GAAU,EAAE,CAAC;IAE9B,YAAY,
|
|
1
|
+
{"version":3,"file":"interactive-shell.js","sourceRoot":"","sources":["../../../../../packages/cli-forge/src/lib/interactive-shell.ts"],"names":[],"mappings":";;;AAAA,qCAAqC;AACrC,mCAAuC;AAEvC,iDAAoD;AACpD,8CAA2C;AAS3C,SAAS,qBAAqB,CAC5B,GAAgB,EAChB,OAAiC;IAEjC,OAAO;QACL,MAAM,EACJ,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,CAAC;IAC9B,CAAC;IAED,KAAK;QACH,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC;QACpE,IAAI,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC;QAChB,QAAQ,CAAC,UAAU,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC,EAAE,CAAC,YAAY,EAAE,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;QACzE,QAAQ,CAAC,eAAe,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QACzC,IAAI,yBAAiB,KAAK,IAAI,EAAE,CAAC;YAC/B,yBAAiB,GAAG,SAAS,CAAC;QAChC,CAAC;IACH,CAAC;CACF;AAzED,4CAyEC"}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { ArgvParser, InternalOptionConfig, OptionConfig, ParsedArgs } from '@cli-forge/parser';
|
|
2
|
+
import { CLI, CLICommandOptions, Command, ErrorHandler } from './public-api';
|
|
3
|
+
/**
|
|
4
|
+
* The base class for a CLI application. This class is used to define the structure of the CLI.
|
|
5
|
+
*
|
|
6
|
+
* {@link cli} is provided as a small helper function to create a new CLI instance.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* import { cli } from 'cli-forge';
|
|
11
|
+
*
|
|
12
|
+
* cli('basic-cli').command('hello', {
|
|
13
|
+
* builder: (args) =>
|
|
14
|
+
* args.option('name', {
|
|
15
|
+
* type: 'string',
|
|
16
|
+
* }),
|
|
17
|
+
* handler: (args) => {
|
|
18
|
+
* console.log(`Hello, ${args.name}!`);
|
|
19
|
+
* }).forge();
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
export declare class InternalCLI<TArgs extends ParsedArgs = ParsedArgs> implements CLI<TArgs> {
|
|
23
|
+
name: string;
|
|
24
|
+
/**
|
|
25
|
+
* For internal use only. Stick to properties available on {@link CLI}.
|
|
26
|
+
*/
|
|
27
|
+
registeredCommands: Record<string, InternalCLI<any>>;
|
|
28
|
+
/**
|
|
29
|
+
* For internal use only. Stick to properties available on {@link CLI}.
|
|
30
|
+
*/
|
|
31
|
+
commandChain: string[];
|
|
32
|
+
private requiresCommand;
|
|
33
|
+
private _configuration?;
|
|
34
|
+
private _versionOverride?;
|
|
35
|
+
private registeredErrorHandlers;
|
|
36
|
+
private registeredMiddleware;
|
|
37
|
+
/**
|
|
38
|
+
* A list of option groups that have been registered with the CLI. Grouped Options are displayed together in the help text.
|
|
39
|
+
*
|
|
40
|
+
* For internal use only. Stick to properties available on {@link CLI}.
|
|
41
|
+
*/
|
|
42
|
+
registeredOptionGroups: Array<{
|
|
43
|
+
label: string;
|
|
44
|
+
sortOrder: number;
|
|
45
|
+
keys: Array<keyof TArgs>;
|
|
46
|
+
}>;
|
|
47
|
+
getGroupedOptions(): {
|
|
48
|
+
label: string;
|
|
49
|
+
sortOrder: number;
|
|
50
|
+
keys: Array<InternalOptionConfig>;
|
|
51
|
+
}[];
|
|
52
|
+
get configuration(): CLICommandOptions<any, any> | undefined;
|
|
53
|
+
private set configuration(value);
|
|
54
|
+
/**
|
|
55
|
+
* The parser used to parse the arguments for the current command.
|
|
56
|
+
*
|
|
57
|
+
* Meant for internal use only. Stick to properties available on {@link CLI}.
|
|
58
|
+
*
|
|
59
|
+
* If you need this kind of info, please open an issue on the GitHub repo with
|
|
60
|
+
* your use case.
|
|
61
|
+
*/
|
|
62
|
+
parser: ArgvParser<TArgs & {
|
|
63
|
+
help: boolean;
|
|
64
|
+
} & {
|
|
65
|
+
version: boolean;
|
|
66
|
+
}>;
|
|
67
|
+
/**
|
|
68
|
+
* @param name What should the name of the cli command be?
|
|
69
|
+
* @param configuration Configuration for the current CLI command.
|
|
70
|
+
*/
|
|
71
|
+
constructor(name: string, rootCommandConfiguration?: CLICommandOptions<TArgs>);
|
|
72
|
+
withRootCommandConfiguration<TRootCommandArgs extends TArgs>(configuration: CLICommandOptions<TArgs, TRootCommandArgs>): InternalCLI<TArgs>;
|
|
73
|
+
command<TCommandArgs extends TArgs>(keyOrCommand: string | Command<TArgs, TCommandArgs>, options?: CLICommandOptions<TArgs, TCommandArgs>): CLI<TArgs>;
|
|
74
|
+
commands(...a0: Command[] | Command[][]): CLI<TArgs>;
|
|
75
|
+
option<TOption extends string, TOptionConfig extends OptionConfig>(name: TOption, config: TOptionConfig): any;
|
|
76
|
+
positional<TOption extends string, TOptionConfig extends OptionConfig>(name: TOption, config: TOptionConfig): any;
|
|
77
|
+
conflicts(...args: [string, string, ...string[]]): CLI<TArgs>;
|
|
78
|
+
implies(option: string, ...impliedOptions: string[]): CLI<TArgs>;
|
|
79
|
+
env(prefix?: string): this;
|
|
80
|
+
demandCommand(): this;
|
|
81
|
+
usage(usageText: string): this;
|
|
82
|
+
examples(...examples: string[]): this;
|
|
83
|
+
version(version?: string): this;
|
|
84
|
+
/**
|
|
85
|
+
* Gets help text for the current command as a string.
|
|
86
|
+
* @returns Help text for the current command.
|
|
87
|
+
*/
|
|
88
|
+
formatHelp(): string;
|
|
89
|
+
/**
|
|
90
|
+
* Prints help text for the current command to the console.
|
|
91
|
+
*/
|
|
92
|
+
printHelp(): void;
|
|
93
|
+
middleware(callback: (args: TArgs) => void): CLI<TArgs>;
|
|
94
|
+
/**
|
|
95
|
+
* Runs the current command.
|
|
96
|
+
* @param cmd The command to run.
|
|
97
|
+
* @param args The arguments to pass to the command.
|
|
98
|
+
*/
|
|
99
|
+
runCommand<T extends ParsedArgs>(args: T, originalArgV: string[]): Promise<void>;
|
|
100
|
+
enableInteractiveShell(): this;
|
|
101
|
+
private versionHandler;
|
|
102
|
+
private withErrorHandlers;
|
|
103
|
+
errorHandler(handler: ErrorHandler): this;
|
|
104
|
+
group(labelOrConfigObject: string | {
|
|
105
|
+
label: string;
|
|
106
|
+
keys: (keyof TArgs)[];
|
|
107
|
+
sortOrder: number;
|
|
108
|
+
}, keys?: (keyof TArgs)[]): CLI<TArgs>;
|
|
109
|
+
/**
|
|
110
|
+
* Parses argv and executes the CLI
|
|
111
|
+
* @param args argv. Defaults to process.argv.slice(2)
|
|
112
|
+
* @returns Promise that resolves when the handler completes.
|
|
113
|
+
*/
|
|
114
|
+
forge: (args?: string[]) => Promise<Awaited<TArgs>>;
|
|
115
|
+
getParser(): import("@cli-forge/parser").ReadonlyArgvParser<TArgs & {
|
|
116
|
+
help: boolean;
|
|
117
|
+
} & {
|
|
118
|
+
version: boolean;
|
|
119
|
+
}>;
|
|
120
|
+
getSubcommands(): Readonly<Record<string, InternalCLI>>;
|
|
121
|
+
clone(): InternalCLI<TArgs>;
|
|
122
|
+
}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.InternalCLI = void 0;
|
|
4
|
-
exports.cli = cli;
|
|
5
4
|
const parser_1 = require("@cli-forge/parser");
|
|
6
5
|
const utils_1 = require("./utils");
|
|
7
6
|
const interactive_shell_1 = require("./interactive-shell");
|
|
7
|
+
const cli_option_groups_1 = require("./cli-option-groups");
|
|
8
|
+
const format_help_1 = require("./format-help");
|
|
8
9
|
/**
|
|
9
10
|
* The base class for a CLI application. This class is used to define the structure of the CLI.
|
|
10
11
|
*
|
|
@@ -48,12 +49,30 @@ class InternalCLI {
|
|
|
48
49
|
}
|
|
49
50
|
},
|
|
50
51
|
];
|
|
52
|
+
registeredMiddleware = [];
|
|
53
|
+
/**
|
|
54
|
+
* A list of option groups that have been registered with the CLI. Grouped Options are displayed together in the help text.
|
|
55
|
+
*
|
|
56
|
+
* For internal use only. Stick to properties available on {@link CLI}.
|
|
57
|
+
*/
|
|
58
|
+
registeredOptionGroups = [];
|
|
59
|
+
getGroupedOptions() {
|
|
60
|
+
return (0, cli_option_groups_1.readOptionGroupsForCLI)(this);
|
|
61
|
+
}
|
|
51
62
|
get configuration() {
|
|
52
63
|
return this._configuration;
|
|
53
64
|
}
|
|
54
65
|
set configuration(value) {
|
|
55
66
|
this._configuration = value;
|
|
56
67
|
}
|
|
68
|
+
/**
|
|
69
|
+
* The parser used to parse the arguments for the current command.
|
|
70
|
+
*
|
|
71
|
+
* Meant for internal use only. Stick to properties available on {@link CLI}.
|
|
72
|
+
*
|
|
73
|
+
* If you need this kind of info, please open an issue on the GitHub repo with
|
|
74
|
+
* your use case.
|
|
75
|
+
*/
|
|
57
76
|
parser = new parser_1.ArgvParser({
|
|
58
77
|
unmatchedParser: (arg) => {
|
|
59
78
|
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
@@ -185,89 +204,7 @@ class InternalCLI {
|
|
|
185
204
|
* @returns Help text for the current command.
|
|
186
205
|
*/
|
|
187
206
|
formatHelp() {
|
|
188
|
-
|
|
189
|
-
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
190
|
-
let command = this;
|
|
191
|
-
for (const key of this.commandChain) {
|
|
192
|
-
command = command.registeredCommands[key];
|
|
193
|
-
}
|
|
194
|
-
help.push(`Usage: ${this.configuration?.usage
|
|
195
|
-
? this.configuration.usage
|
|
196
|
-
: [
|
|
197
|
-
this.name,
|
|
198
|
-
...this.commandChain,
|
|
199
|
-
...command.parser.configuredPositionals.map((p) => p.required ? `<${p.key}>` : `[${p.key}]`),
|
|
200
|
-
].join(' ')}`);
|
|
201
|
-
if (command.configuration?.description) {
|
|
202
|
-
help.push(command.configuration.description);
|
|
203
|
-
}
|
|
204
|
-
if (Object.keys(command.registeredCommands).length > 0) {
|
|
205
|
-
help.push('');
|
|
206
|
-
help.push('Commands:');
|
|
207
|
-
}
|
|
208
|
-
for (const key in command.registeredCommands) {
|
|
209
|
-
const subcommand = command.registeredCommands[key];
|
|
210
|
-
help.push(` ${key}${subcommand.configuration?.description
|
|
211
|
-
? ' - ' + subcommand.configuration.description
|
|
212
|
-
: ''}`);
|
|
213
|
-
}
|
|
214
|
-
const nonpositionalOptions = Object.values(command.parser.configuredOptions).filter((c) => !c.positional);
|
|
215
|
-
if (nonpositionalOptions.length > 0) {
|
|
216
|
-
help.push('');
|
|
217
|
-
help.push('Options:');
|
|
218
|
-
}
|
|
219
|
-
function getOptionParts(option) {
|
|
220
|
-
const parts = [];
|
|
221
|
-
if (option.description) {
|
|
222
|
-
parts.push(option.description);
|
|
223
|
-
}
|
|
224
|
-
if (option.choices) {
|
|
225
|
-
const choices = typeof option.choices === 'function'
|
|
226
|
-
? option.choices()
|
|
227
|
-
: option.choices;
|
|
228
|
-
parts.push(`(${choices.join(', ')})`);
|
|
229
|
-
}
|
|
230
|
-
if (option.default) {
|
|
231
|
-
parts.push('[default: ' + option.default + ']');
|
|
232
|
-
}
|
|
233
|
-
else if (option.required) {
|
|
234
|
-
parts.push('[required]');
|
|
235
|
-
}
|
|
236
|
-
if (option.deprecated) {
|
|
237
|
-
parts.push('[deprecated: ' + option.deprecated + ']');
|
|
238
|
-
}
|
|
239
|
-
return parts;
|
|
240
|
-
}
|
|
241
|
-
const allParts = [];
|
|
242
|
-
for (const option of nonpositionalOptions) {
|
|
243
|
-
allParts.push([option.key, ...getOptionParts(option)]);
|
|
244
|
-
}
|
|
245
|
-
const paddingValues = [];
|
|
246
|
-
for (let i = 0; i < allParts.length; i++) {
|
|
247
|
-
for (let j = 0; j < allParts[i].length; j++) {
|
|
248
|
-
if (!paddingValues[j]) {
|
|
249
|
-
paddingValues[j] = 0;
|
|
250
|
-
}
|
|
251
|
-
paddingValues[j] = Math.max(paddingValues[j], allParts[i][j].length);
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
for (const [key, ...parts] of allParts) {
|
|
255
|
-
help.push(` --${key.padEnd(paddingValues[0])}${parts.length ? ' - ' : ''}${parts
|
|
256
|
-
.map((part, i) => part.padEnd(paddingValues[i + 1]))
|
|
257
|
-
.join(' ')}`);
|
|
258
|
-
}
|
|
259
|
-
if (command.configuration?.examples?.length) {
|
|
260
|
-
help.push('');
|
|
261
|
-
help.push('Examples:');
|
|
262
|
-
for (const example of command.configuration.examples) {
|
|
263
|
-
help.push(` \`${example}\``);
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
if (Object.keys(command.registeredCommands).length > 0) {
|
|
267
|
-
help.push(' ');
|
|
268
|
-
help.push(`Run \`${[this.name, ...this.commandChain].join(' ')} [command] --help\` for more information on a command`);
|
|
269
|
-
}
|
|
270
|
-
return help.join('\n');
|
|
207
|
+
return (0, format_help_1.formatHelp)(this);
|
|
271
208
|
}
|
|
272
209
|
/**
|
|
273
210
|
* Prints help text for the current command to the console.
|
|
@@ -275,17 +212,33 @@ class InternalCLI {
|
|
|
275
212
|
printHelp() {
|
|
276
213
|
console.log(this.formatHelp());
|
|
277
214
|
}
|
|
215
|
+
middleware(callback) {
|
|
216
|
+
this.registeredMiddleware.push(callback);
|
|
217
|
+
return this;
|
|
218
|
+
}
|
|
278
219
|
/**
|
|
279
220
|
* Runs the current command.
|
|
280
221
|
* @param cmd The command to run.
|
|
281
222
|
* @param args The arguments to pass to the command.
|
|
282
223
|
*/
|
|
283
|
-
async runCommand(
|
|
224
|
+
async runCommand(args, originalArgV) {
|
|
225
|
+
const middlewares = [
|
|
226
|
+
...this.registeredMiddleware,
|
|
227
|
+
];
|
|
228
|
+
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
229
|
+
let cmd = this;
|
|
230
|
+
for (const command of this.commandChain) {
|
|
231
|
+
cmd = cmd.registeredCommands[command];
|
|
232
|
+
middlewares.push(...cmd.registeredMiddleware);
|
|
233
|
+
}
|
|
284
234
|
try {
|
|
285
235
|
if (cmd.requiresCommand) {
|
|
286
236
|
throw new Error(`${[this.name, ...this.commandChain].join(' ')} requires a command`);
|
|
287
237
|
}
|
|
288
238
|
if (cmd.configuration?.handler) {
|
|
239
|
+
for (const middleware of middlewares) {
|
|
240
|
+
await middleware(args);
|
|
241
|
+
}
|
|
289
242
|
await cmd.configuration.handler(args, {
|
|
290
243
|
command: cmd,
|
|
291
244
|
});
|
|
@@ -294,7 +247,11 @@ class InternalCLI {
|
|
|
294
247
|
// We can treat a command as a subshell if it has subcommands
|
|
295
248
|
if (Object.keys(cmd.registeredCommands).length > 0) {
|
|
296
249
|
cmd.command('help', { handler: () => this.printHelp() });
|
|
297
|
-
if (!
|
|
250
|
+
if (!process.stdout.isTTY) {
|
|
251
|
+
// If we're not in a TTY, we can't run an interactive shell...
|
|
252
|
+
// Maybe we should warn here?
|
|
253
|
+
}
|
|
254
|
+
else if (!interactive_shell_1.INTERACTIVE_SHELL) {
|
|
298
255
|
const tui = new interactive_shell_1.InteractiveShell(this, {
|
|
299
256
|
prependArgs: originalArgV,
|
|
300
257
|
});
|
|
@@ -347,7 +304,6 @@ class InternalCLI {
|
|
|
347
304
|
return await cb();
|
|
348
305
|
}
|
|
349
306
|
catch (e) {
|
|
350
|
-
let handled = false;
|
|
351
307
|
for (const handler of this.registeredErrorHandlers) {
|
|
352
308
|
try {
|
|
353
309
|
handler(e, {
|
|
@@ -362,16 +318,27 @@ class InternalCLI {
|
|
|
362
318
|
// Error was not handled, continue to the next handler
|
|
363
319
|
}
|
|
364
320
|
}
|
|
365
|
-
|
|
366
|
-
throw e;
|
|
367
|
-
}
|
|
321
|
+
throw e;
|
|
368
322
|
}
|
|
369
|
-
return {};
|
|
370
323
|
}
|
|
371
324
|
errorHandler(handler) {
|
|
372
325
|
this.registeredErrorHandlers.unshift(handler);
|
|
373
326
|
return this;
|
|
374
327
|
}
|
|
328
|
+
group(labelOrConfigObject, keys) {
|
|
329
|
+
const config = typeof labelOrConfigObject === 'object'
|
|
330
|
+
? labelOrConfigObject
|
|
331
|
+
: {
|
|
332
|
+
label: labelOrConfigObject,
|
|
333
|
+
keys: keys,
|
|
334
|
+
sortOrder: Object.keys(this.registeredOptionGroups).length,
|
|
335
|
+
};
|
|
336
|
+
if (!config.keys) {
|
|
337
|
+
throw new Error('keys must be provided when calling `group`.');
|
|
338
|
+
}
|
|
339
|
+
this.registeredOptionGroups.push(config);
|
|
340
|
+
return this;
|
|
341
|
+
}
|
|
375
342
|
/**
|
|
376
343
|
* Parses argv and executes the CLI
|
|
377
344
|
* @param args argv. Defaults to process.argv.slice(2)
|
|
@@ -411,15 +378,10 @@ class InternalCLI {
|
|
|
411
378
|
else if (validationFailedError) {
|
|
412
379
|
throw validationFailedError;
|
|
413
380
|
}
|
|
414
|
-
const finalArgV =
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
}
|
|
419
|
-
}
|
|
420
|
-
return argv;
|
|
421
|
-
})();
|
|
422
|
-
await this.runCommand(currentCommand, finalArgV, args);
|
|
381
|
+
const finalArgV = this.commandChain.length === 0 && this.configuration?.builder
|
|
382
|
+
? (this.configuration.builder?.(this)).parser.parse(args)
|
|
383
|
+
: argv;
|
|
384
|
+
await this.runCommand(finalArgV, args);
|
|
423
385
|
return finalArgV;
|
|
424
386
|
});
|
|
425
387
|
getParser() {
|
|
@@ -445,14 +407,4 @@ class InternalCLI {
|
|
|
445
407
|
}
|
|
446
408
|
}
|
|
447
409
|
exports.InternalCLI = InternalCLI;
|
|
448
|
-
|
|
449
|
-
* Constructs a CLI instance. See {@link InternalCLI} for more information.
|
|
450
|
-
* @param name Name for the top level CLI
|
|
451
|
-
* @param rootCommandConfiguration Configuration used when running the bare CLI. e.g. npx my-cli, rather than npx my-cli [cmd]
|
|
452
|
-
* @returns A {@link InternalCLI} instance.
|
|
453
|
-
*/
|
|
454
|
-
function cli(name, rootCommandConfiguration) {
|
|
455
|
-
return new InternalCLI(name, rootCommandConfiguration);
|
|
456
|
-
}
|
|
457
|
-
exports.default = cli;
|
|
458
|
-
//# sourceMappingURL=cli-forge.js.map
|
|
410
|
+
//# sourceMappingURL=internal-cli.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"internal-cli.js","sourceRoot":"","sources":["../../../../../packages/cli-forge/src/lib/internal-cli.ts"],"names":[],"mappings":";;;AAAA,8CAQ2B;AAC3B,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