cli-forge 0.3.0 → 0.4.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.d.ts +4 -1
- package/bin/cli.js +1 -1
- package/bin/cli.js.map +1 -1
- package/bin/commands/generate-documentation.d.ts +3 -18
- package/bin/commands/generate-documentation.js +28 -29
- package/bin/commands/generate-documentation.js.map +1 -1
- package/bin/commands/init.d.ts +6 -9
- package/bin/commands/init.js +33 -33
- package/bin/commands/init.js.map +1 -1
- package/package.json +2 -2
- package/src/index.d.ts +1 -2
- package/src/index.js +2 -3
- package/src/index.js.map +1 -1
- package/src/lib/cli-forge.d.ts +96 -57
- package/src/lib/cli-forge.js +84 -60
- package/src/lib/cli-forge.js.map +1 -1
- package/src/lib/documentation.d.ts +2 -2
- package/src/lib/documentation.js.map +1 -1
package/bin/cli.d.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
declare const mycli: import("../src").CLI<
|
|
2
|
+
declare const mycli: import("../src").CLI<{
|
|
3
|
+
unmatched: string[];
|
|
4
|
+
'--'?: string[];
|
|
5
|
+
}>;
|
|
3
6
|
export default mycli;
|
package/bin/cli.js
CHANGED
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
4
4
|
const src_1 = require("../src");
|
|
5
5
|
const generate_documentation_1 = require("./commands/generate-documentation");
|
|
6
6
|
const init_1 = require("./commands/init");
|
|
7
|
-
const mycli = (0,
|
|
7
|
+
const mycli = (0, src_1.cli)('cli-forge').commands(generate_documentation_1.generateDocumentationCommand, init_1.initCommand);
|
|
8
8
|
exports.default = mycli;
|
|
9
9
|
mycli.forge();
|
|
10
10
|
//# sourceMappingURL=cli.js.map
|
package/bin/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../../../../packages/cli-forge/bin/cli.ts"],"names":[],"mappings":";;;AAEA,gCAA6B;AAC7B,
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../../../../packages/cli-forge/bin/cli.ts"],"names":[],"mappings":";;;AAEA,gCAA6B;AAC7B,8EAAiF;AACjF,0CAA8C;AAE9C,MAAM,KAAK,GAAG,IAAA,SAAG,EAAC,WAAW,CAAC,CAAC,QAAQ,CACrC,qDAA4B,EAC5B,kBAAW,CACZ,CAAC;AAEF,kBAAe,KAAK,CAAC;AAErB,KAAK,CAAC,KAAK,EAAE,CAAC"}
|
|
@@ -1,20 +1,6 @@
|
|
|
1
1
|
import type { ParsedArgs } from '@cli-forge/parser';
|
|
2
|
-
import { CLI } from '../../src';
|
|
3
|
-
|
|
4
|
-
cli: string;
|
|
5
|
-
output: string;
|
|
6
|
-
format: string;
|
|
7
|
-
export: string;
|
|
8
|
-
};
|
|
9
|
-
export declare function withGenerateDocumentationArgs<T extends ParsedArgs>(cmd: CLI<T, T & GenerateDocsArgs>): CLI<T & {
|
|
10
|
-
cli: string;
|
|
11
|
-
} & {
|
|
12
|
-
output: string;
|
|
13
|
-
} & {
|
|
14
|
-
format: string;
|
|
15
|
-
} & {
|
|
16
|
-
export: string;
|
|
17
|
-
}, T & {
|
|
2
|
+
import { CLI } from '../../src/lib/cli-forge';
|
|
3
|
+
export declare function withGenerateDocumentationArgs<T extends ParsedArgs>(cmd: CLI<T>): CLI<T & {
|
|
18
4
|
cli: string;
|
|
19
5
|
} & {
|
|
20
6
|
output: string;
|
|
@@ -23,5 +9,4 @@ export declare function withGenerateDocumentationArgs<T extends ParsedArgs>(cmd:
|
|
|
23
9
|
} & {
|
|
24
10
|
export: string;
|
|
25
11
|
}>;
|
|
26
|
-
export declare
|
|
27
|
-
export {};
|
|
12
|
+
export declare const generateDocumentationCommand: CLI;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.generateDocumentationCommand = void 0;
|
|
3
4
|
exports.withGenerateDocumentationArgs = withGenerateDocumentationArgs;
|
|
4
|
-
exports.withGenerateDocumentation = withGenerateDocumentation;
|
|
5
5
|
const node_fs_1 = require("node:fs");
|
|
6
6
|
const node_path_1 = require("node:path");
|
|
7
7
|
const src_1 = require("../../src");
|
|
8
8
|
const documentation_1 = require("../../src/lib/documentation");
|
|
9
|
+
const cli_forge_1 = require("../../src/lib/cli-forge");
|
|
9
10
|
const fs_1 = require("../utils/fs");
|
|
10
11
|
function withGenerateDocumentationArgs(cmd) {
|
|
11
12
|
return cmd
|
|
@@ -30,34 +31,32 @@ function withGenerateDocumentationArgs(cmd) {
|
|
|
30
31
|
description: 'The name of the export that contains the CLI instance. By default, docs will be generated for the default export.',
|
|
31
32
|
});
|
|
32
33
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
});
|
|
60
|
-
}
|
|
34
|
+
exports.generateDocumentationCommand = (0, src_1.default)('generate-documentation', {
|
|
35
|
+
description: 'Generate documentation for the given CLI',
|
|
36
|
+
builder: (b) => withGenerateDocumentationArgs(b),
|
|
37
|
+
handler: async (args) => {
|
|
38
|
+
if (args.cli.startsWith('./')) {
|
|
39
|
+
args.cli = (0, node_path_1.join)(process.cwd(), args.cli);
|
|
40
|
+
}
|
|
41
|
+
const cliModule = await Promise.resolve(`${args.cli}`).then(s => require(s));
|
|
42
|
+
const cli = cliModule[args.export || 'default'] ?? cliModule;
|
|
43
|
+
if (!(cli instanceof cli_forge_1.InternalCLI)) {
|
|
44
|
+
throw new Error(`${args.cli}${args.export ? '#' + args.export : ''} is not a CLI.`);
|
|
45
|
+
}
|
|
46
|
+
const documentation = (0, documentation_1.generateDocumentation)(cli);
|
|
47
|
+
if (args.format === 'md') {
|
|
48
|
+
await generateMarkdownDocumentation(documentation, args);
|
|
49
|
+
}
|
|
50
|
+
else if (args.format === 'json') {
|
|
51
|
+
const outfile = args.output.endsWith('json')
|
|
52
|
+
? args.output
|
|
53
|
+
: (0, node_path_1.join)(args.output, cli.name + '.json');
|
|
54
|
+
const outdir = (0, node_path_1.dirname)(outfile);
|
|
55
|
+
(0, fs_1.ensureDirSync)(outdir);
|
|
56
|
+
(0, node_fs_1.writeFileSync)(outfile, JSON.stringify(documentation, null, 2));
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
});
|
|
61
60
|
async function generateMarkdownDocumentation(docs, args) {
|
|
62
61
|
const md = await importMarkdownFactory();
|
|
63
62
|
await generateMarkdownForSingleCommand(docs, (0, node_path_1.join)(args.output, docs.name), md);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate-documentation.js","sourceRoot":"","sources":["../../../../../packages/cli-forge/bin/commands/generate-documentation.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"generate-documentation.js","sourceRoot":"","sources":["../../../../../packages/cli-forge/bin/commands/generate-documentation.ts"],"names":[],"mappings":";;;AAsBA,sEA0BC;AA9CD,qCAAwC;AACxC,yCAA0C;AAE1C,mCAA4B;AAC5B,+DAGqC;AACrC,uDAA2D;AAC3D,oCAA4C;AAW5C,SAAgB,6BAA6B,CAC3C,GAAW;IAEX,OAAO,GAAG;SACP,UAAU,CAAC,KAAK,EAAE;QACjB,IAAI,EAAE,QAAQ;QACd,WAAW,EAAE,oDAAoD;QACjE,QAAQ,EAAE,IAAI;KACf,CAAC;SACD,MAAM,CAAC,QAAQ,EAAE;QAChB,KAAK,EAAE,CAAC,GAAG,CAAC;QACZ,IAAI,EAAE,QAAQ;QACd,W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AK,UAAU,qBAAqB;IAClC,IAAI,CAAC;QACH,OAAO,2CAAa,kBAAkB,EAAC,CAAC;IAC1C,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,IAAI,KAAK,CACb,wFAAwF,CACzF,CAAC;IACJ,CAAC;AACH,CAAC"}
|
package/bin/commands/init.d.ts
CHANGED
|
@@ -1,22 +1,19 @@
|
|
|
1
1
|
import type { ParsedArgs } from '@cli-forge/parser';
|
|
2
2
|
import { CLI } from '../../src';
|
|
3
|
-
|
|
4
|
-
cliName: string;
|
|
5
|
-
output: string;
|
|
6
|
-
format: string;
|
|
7
|
-
};
|
|
8
|
-
export declare function withInitArgs<T extends ParsedArgs>(cmd: CLI<T, T & InitArgs>): CLI<T & {
|
|
3
|
+
export declare function withInitArgs<T extends ParsedArgs>(cmd: CLI<T>): CLI<T & {
|
|
9
4
|
cliName: string;
|
|
10
5
|
} & {
|
|
11
6
|
output: string;
|
|
12
7
|
} & {
|
|
13
8
|
format: string;
|
|
14
|
-
}
|
|
9
|
+
}>;
|
|
10
|
+
export declare const initCommand: CLI<{
|
|
11
|
+
unmatched: string[];
|
|
12
|
+
'--'?: string[];
|
|
13
|
+
} & {
|
|
15
14
|
cliName: string;
|
|
16
15
|
} & {
|
|
17
16
|
output: string;
|
|
18
17
|
} & {
|
|
19
18
|
format: string;
|
|
20
19
|
}>;
|
|
21
|
-
export declare function withInit<T extends ParsedArgs>(cli: CLI<T>): CLI<T, T>;
|
|
22
|
-
export {};
|
package/bin/commands/init.js
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.initCommand = void 0;
|
|
3
4
|
exports.withInitArgs = withInitArgs;
|
|
4
|
-
|
|
5
|
+
const node_child_process_1 = require("node:child_process");
|
|
5
6
|
const node_fs_1 = require("node:fs");
|
|
6
7
|
const node_path_1 = require("node:path");
|
|
7
|
-
const fs_1 = require("../utils/fs");
|
|
8
8
|
const package_json_1 = require("../../package.json");
|
|
9
|
-
const
|
|
9
|
+
const src_1 = require("../../src");
|
|
10
|
+
// import { CLI } from '../../src/lib/cli-forge';
|
|
11
|
+
const fs_1 = require("../utils/fs");
|
|
10
12
|
function withInitArgs(cmd) {
|
|
11
13
|
return cmd
|
|
12
14
|
.positional('cliName', {
|
|
@@ -25,36 +27,34 @@ function withInitArgs(cmd) {
|
|
|
25
27
|
description: 'What format should the CLI be in? (js, ts)',
|
|
26
28
|
});
|
|
27
29
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
});
|
|
57
|
-
}
|
|
30
|
+
exports.initCommand = (0, src_1.default)('init', {
|
|
31
|
+
description: 'Generate a new CLI',
|
|
32
|
+
builder: (b) => withInitArgs(b),
|
|
33
|
+
handler: async (args) => {
|
|
34
|
+
args.output ??= process.cwd();
|
|
35
|
+
(0, fs_1.ensureDirSync)(args.output);
|
|
36
|
+
const packageJsonPath = (0, node_path_1.join)(args.output, 'package.json');
|
|
37
|
+
const cliPath = (0, node_path_1.join)(args.output, 'bin', `${args.cliName}.${args.format}`);
|
|
38
|
+
const packageJsonContent = readJsonOr(packageJsonPath, { name: args.cliName });
|
|
39
|
+
packageJsonContent.bin ??= {};
|
|
40
|
+
packageJsonContent.bin[args.cliName] = (0, node_path_1.relative)(args.output, cliPath);
|
|
41
|
+
packageJsonContent.dependencies ??= {};
|
|
42
|
+
packageJsonContent.dependencies['cli-forge'] ??= package_json_1.version;
|
|
43
|
+
(0, node_fs_1.writeFileSync)(packageJsonPath, JSON.stringify(packageJsonContent, null, 2));
|
|
44
|
+
(0, fs_1.ensureDirSync)((0, node_path_1.dirname)(cliPath));
|
|
45
|
+
(0, node_fs_1.writeFileSync)(cliPath, args.format === 'ts'
|
|
46
|
+
? TS_CLI_CONTENTS(args.cliName)
|
|
47
|
+
: JS_CLI_CONTENTS(args.cliName));
|
|
48
|
+
const installCommand = (0, node_fs_1.existsSync)((0, node_path_1.join)(args.output, 'yarn.lock'))
|
|
49
|
+
? 'yarn'
|
|
50
|
+
: (0, node_fs_1.existsSync)((0, node_path_1.join)(args.output, 'pnpm-lock.yaml'))
|
|
51
|
+
? 'pnpm'
|
|
52
|
+
: (0, node_fs_1.existsSync)((0, node_path_1.join)(args.output, 'bun.lockb'))
|
|
53
|
+
? 'bun'
|
|
54
|
+
: 'npm';
|
|
55
|
+
(0, node_child_process_1.execSync)(`${installCommand} install`);
|
|
56
|
+
},
|
|
57
|
+
});
|
|
58
58
|
const COMMON_CONTENTS = (name) => `const myCLI = cli('${name}')
|
|
59
59
|
.command('hello', {
|
|
60
60
|
builder: (args) => args.positional('name', {type: 'string'}),
|
package/bin/commands/init.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.js","sourceRoot":"","sources":["../../../../../packages/cli-forge/bin/commands/init.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"init.js","sourceRoot":"","sources":["../../../../../packages/cli-forge/bin/commands/init.ts"],"names":[],"mappings":";;;AAWA,oCAiBC;AA1BD,2DAA8C;AAC9C,qCAAkE;AAClE,yCAAoD;AAEpD,qDAAkE;AAClE,mCAAqC;AACrC,iDAAiD;AACjD,oCAA4C;AAE5C,SAAgB,YAAY,CAAuB,GAAW;IAC5D,OAAO,GAAG;SACP,UAAU,CAAC,SAAS,EAAE;QACrB,IAAI,EAAE,QAAQ;QACd,WAAW,EAAE,8BAA8B;QAC3C,QAAQ,EAAE,IAAI;KACf,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BAAY,EAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;QACjD,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IAC9B,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,GAAG,CAAC;IACb,CAAC;AACH,CAAC"}
|
package/package.json
CHANGED
package/src/index.d.ts
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export
|
|
2
|
-
export { default } from './lib/cli-forge';
|
|
1
|
+
export { default, cli, CLI, Command } from './lib/cli-forge';
|
package/src/index.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.default = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
tslib_1.__exportStar(require("./lib/cli-forge"), exports);
|
|
3
|
+
exports.cli = exports.default = void 0;
|
|
6
4
|
var cli_forge_1 = require("./lib/cli-forge");
|
|
7
5
|
Object.defineProperty(exports, "default", { enumerable: true, get: function () { return cli_forge_1.default; } });
|
|
6
|
+
Object.defineProperty(exports, "cli", { enumerable: true, get: function () { return cli_forge_1.cli; } });
|
|
8
7
|
//# sourceMappingURL=index.js.map
|
package/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../packages/cli-forge/src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../packages/cli-forge/src/index.ts"],"names":[],"mappings":";;;AAAA,6CAA6D;AAApD,oGAAA,OAAO,OAAA;AAAE,gGAAA,GAAG,OAAA"}
|
package/src/lib/cli-forge.d.ts
CHANGED
|
@@ -1,52 +1,34 @@
|
|
|
1
1
|
import { ArrayOptionConfig, OptionConfig, ParsedArgs } from '@cli-forge/parser';
|
|
2
|
-
export
|
|
2
|
+
export interface CLIHandlerContext {
|
|
3
|
+
command: CLI<any>;
|
|
4
|
+
}
|
|
5
|
+
export type CLICommandOptions<TInitial extends ParsedArgs, TArgs extends TInitial = TInitial> = {
|
|
3
6
|
description?: string;
|
|
4
7
|
builder?: (parser: CLI<TInitial>) => CLI<TArgs>;
|
|
5
|
-
handler: (args: TArgs) => void | Promise<void>;
|
|
8
|
+
handler: (args: TArgs, context: CLIHandlerContext) => void | Promise<void>;
|
|
6
9
|
};
|
|
7
|
-
export type
|
|
8
|
-
configuration: {
|
|
9
|
-
handler: (args: infer TArgs) => void;
|
|
10
|
-
};
|
|
11
|
-
} ? TArgs : never;
|
|
12
|
-
/**
|
|
13
|
-
* The base class for a CLI application. This class is used to define the structure of the CLI.
|
|
14
|
-
*
|
|
15
|
-
* {@link cli} is provided as a small helper function to create a new CLI instance.
|
|
16
|
-
*
|
|
17
|
-
* @example
|
|
18
|
-
* ```ts
|
|
19
|
-
* import { cli } from 'cli-forge';
|
|
20
|
-
*
|
|
21
|
-
* cli('basic-cli').command('hello', {
|
|
22
|
-
* builder: (args) =>
|
|
23
|
-
* args.option('name', {
|
|
24
|
-
* type: 'string',
|
|
25
|
-
* }),
|
|
26
|
-
* handler: (args) => {
|
|
27
|
-
* console.log(`Hello, ${args.name}!`);
|
|
28
|
-
* }).forge();
|
|
29
|
-
* ```
|
|
30
|
-
*/
|
|
31
|
-
export declare class CLI<T extends ParsedArgs = ParsedArgs, T2 extends T = T> {
|
|
10
|
+
export type Command<TInitial extends ParsedArgs = any, TArgs extends TInitial = TInitial> = ({
|
|
32
11
|
name: string;
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
private requiresCommand;
|
|
37
|
-
private parser;
|
|
38
|
-
/**
|
|
39
|
-
* @param name What should the name of the cli command be?
|
|
40
|
-
* @param configuration Configuration for the current CLI command.
|
|
41
|
-
*/
|
|
42
|
-
constructor(name: string, configuration?: CLICommandOptions<T, T2> | undefined);
|
|
12
|
+
} & CLICommandOptions<TInitial, TArgs>) | CLI<TArgs>;
|
|
13
|
+
export interface CLI<TArgs extends ParsedArgs = ParsedArgs> {
|
|
14
|
+
command<TCommandArgs extends TArgs>(cmd: Command<TArgs, TCommandArgs>): CLI<TArgs>;
|
|
43
15
|
/**
|
|
44
16
|
* Registers a new command with the CLI.
|
|
45
17
|
* @param key What should the new command be called?
|
|
46
18
|
* @param options Settings for the new command. See {@link CLICommandOptions}.
|
|
47
19
|
* @returns Updated CLI instance with the new command registered.
|
|
48
20
|
*/
|
|
49
|
-
command<
|
|
21
|
+
command<TCommandArgs extends TArgs>(key: string, options: CLICommandOptions<TArgs, TCommandArgs>): CLI<TArgs>;
|
|
22
|
+
/**
|
|
23
|
+
* Registers multiple subcommands with the CLI.
|
|
24
|
+
* @param commands Several commands to register. Can be the result of a call to {@link cli} or a configuration object.
|
|
25
|
+
*/
|
|
26
|
+
commands(commands: Command[]): CLI<TArgs>;
|
|
27
|
+
/**
|
|
28
|
+
* Registers multiple subcommands with the CLI.
|
|
29
|
+
* @param commands Several commands to register. Can be the result of a call to {@link cli} or a configuration object.
|
|
30
|
+
*/
|
|
31
|
+
commands(...commands: Command[]): CLI<TArgs>;
|
|
50
32
|
/**
|
|
51
33
|
* Registers a new option for the CLI command. This option will be accessible
|
|
52
34
|
* within the command handler, as well as any subcommands.
|
|
@@ -55,12 +37,14 @@ export declare class CLI<T extends ParsedArgs = ParsedArgs, T2 extends T = T> {
|
|
|
55
37
|
* @param config Configuration for the option. See {@link OptionConfig}.
|
|
56
38
|
* @returns Updated CLI instance with the new option registered.
|
|
57
39
|
*/
|
|
58
|
-
option<TOption extends string, TOptionConfig extends OptionConfig>(name: TOption, config: TOptionConfig): CLI<
|
|
59
|
-
string:
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
40
|
+
option<TOption extends string, TOptionConfig extends OptionConfig>(name: TOption, config: TOptionConfig): CLI<TArgs & {
|
|
41
|
+
[key in TOption]: TOptionConfig['coerce'] extends (value: string) => infer TCoerce ? TCoerce : {
|
|
42
|
+
string: string;
|
|
43
|
+
number: number;
|
|
44
|
+
boolean: boolean;
|
|
45
|
+
array: (TOptionConfig extends ArrayOptionConfig<string | number> ? TOptionConfig['items'] extends 'string' ? string : number : never)[];
|
|
46
|
+
}[TOptionConfig['type']];
|
|
47
|
+
}>;
|
|
64
48
|
/**
|
|
65
49
|
* Registers a new positional argument for the CLI command. This argument will be accessible
|
|
66
50
|
* within the command handler, as well as any subcommands.
|
|
@@ -68,17 +52,71 @@ export declare class CLI<T extends ParsedArgs = ParsedArgs, T2 extends T = T> {
|
|
|
68
52
|
* @param config Configuration for the positional argument. See {@link OptionConfig}.
|
|
69
53
|
* @returns Updated CLI instance with the new positional argument registered.
|
|
70
54
|
*/
|
|
71
|
-
positional<TOption extends string, TOptionConfig extends OptionConfig>(name: TOption, config: TOptionConfig): CLI<
|
|
72
|
-
string:
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
55
|
+
positional<TOption extends string, TOptionConfig extends OptionConfig>(name: TOption, config: TOptionConfig): CLI<TArgs & {
|
|
56
|
+
[key in TOption]: TOptionConfig['coerce'] extends (value: string) => infer TCoerce ? TCoerce : {
|
|
57
|
+
string: string;
|
|
58
|
+
number: number;
|
|
59
|
+
boolean: boolean;
|
|
60
|
+
array: (TOptionConfig extends ArrayOptionConfig<string | number> ? TOptionConfig['items'] extends 'string' ? string : number : never)[];
|
|
61
|
+
}[TOptionConfig['type']];
|
|
62
|
+
}>;
|
|
77
63
|
/**
|
|
78
64
|
* Requires a command to be provided when executing the CLI. Useful if your parent command
|
|
79
65
|
* cannot be executed on its own.
|
|
80
66
|
* @returns Updated CLI instance.
|
|
81
67
|
*/
|
|
68
|
+
demandCommand(): CLI<TArgs>;
|
|
69
|
+
/**
|
|
70
|
+
* Prints help text to stdout.
|
|
71
|
+
*/
|
|
72
|
+
printHelp(): void;
|
|
73
|
+
/**
|
|
74
|
+
* Parses argv and executes the CLI
|
|
75
|
+
* @param args argv. Defaults to process.argv.slice(2)
|
|
76
|
+
* @returns Promise that resolves when the handler completes.
|
|
77
|
+
*/
|
|
78
|
+
forge(args?: string[]): Promise<void>;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* The base class for a CLI application. This class is used to define the structure of the CLI.
|
|
82
|
+
*
|
|
83
|
+
* {@link cli} is provided as a small helper function to create a new CLI instance.
|
|
84
|
+
*
|
|
85
|
+
* @example
|
|
86
|
+
* ```ts
|
|
87
|
+
* import { cli } from 'cli-forge';
|
|
88
|
+
*
|
|
89
|
+
* cli('basic-cli').command('hello', {
|
|
90
|
+
* builder: (args) =>
|
|
91
|
+
* args.option('name', {
|
|
92
|
+
* type: 'string',
|
|
93
|
+
* }),
|
|
94
|
+
* handler: (args) => {
|
|
95
|
+
* console.log(`Hello, ${args.name}!`);
|
|
96
|
+
* }).forge();
|
|
97
|
+
* ```
|
|
98
|
+
*/
|
|
99
|
+
export declare class InternalCLI<TArgs extends ParsedArgs = ParsedArgs> implements CLI<TArgs> {
|
|
100
|
+
name: string;
|
|
101
|
+
private registeredCommands;
|
|
102
|
+
private commandChain;
|
|
103
|
+
private requiresCommand;
|
|
104
|
+
private _configuration?;
|
|
105
|
+
private parser;
|
|
106
|
+
/**
|
|
107
|
+
* @param name What should the name of the cli command be?
|
|
108
|
+
* @param configuration Configuration for the current CLI command.
|
|
109
|
+
*/
|
|
110
|
+
constructor(name: string);
|
|
111
|
+
get configuration(): CLICommandOptions<any, any> | undefined;
|
|
112
|
+
private set configuration(value);
|
|
113
|
+
withRootCommandConfiguration<TRootCommandArgs extends TArgs>(configuration: CLICommandOptions<TArgs, TRootCommandArgs>): InternalCLI<TArgs>;
|
|
114
|
+
command<TCommandArgs extends TArgs>(cmd: Command<TArgs, TCommandArgs>): CLI<TArgs>;
|
|
115
|
+
command<TCommandArgs extends TArgs>(key: string, options: CLICommandOptions<TArgs, TCommandArgs>): CLI<TArgs>;
|
|
116
|
+
commands(commands: Command[]): typeof this;
|
|
117
|
+
commands(...commands: Command[]): typeof this;
|
|
118
|
+
option<TOption extends string, TOptionConfig extends OptionConfig>(name: TOption, config: TOptionConfig): any;
|
|
119
|
+
positional<TOption extends string, TOptionConfig extends OptionConfig>(name: TOption, config: TOptionConfig): any;
|
|
82
120
|
demandCommand(): this;
|
|
83
121
|
/**
|
|
84
122
|
* Gets help text for the current command as a string.
|
|
@@ -94,23 +132,24 @@ export declare class CLI<T extends ParsedArgs = ParsedArgs, T2 extends T = T> {
|
|
|
94
132
|
* @param cmd The command to run.
|
|
95
133
|
* @param args The arguments to pass to the command.
|
|
96
134
|
*/
|
|
97
|
-
runCommand<T extends ParsedArgs>(cmd:
|
|
135
|
+
runCommand<T extends ParsedArgs>(cmd: InternalCLI<T>, args: T): Promise<void>;
|
|
98
136
|
/**
|
|
99
137
|
* Parses argv and executes the CLI
|
|
100
138
|
* @param args argv. Defaults to process.argv.slice(2)
|
|
101
139
|
* @returns Promise that resolves when the handler completes.
|
|
102
140
|
*/
|
|
103
141
|
forge(args?: string[]): Promise<void>;
|
|
104
|
-
getParser(): import("@cli-forge/parser").ReadonlyArgvParser<
|
|
142
|
+
getParser(): import("@cli-forge/parser").ReadonlyArgvParser<TArgs & {
|
|
105
143
|
help: boolean;
|
|
106
144
|
}>;
|
|
107
|
-
getSubcommands(): Readonly<Record<string,
|
|
108
|
-
clone():
|
|
145
|
+
getSubcommands(): Readonly<Record<string, InternalCLI>>;
|
|
146
|
+
clone(): InternalCLI<TArgs>;
|
|
109
147
|
}
|
|
110
148
|
/**
|
|
111
|
-
* Constructs a CLI instance. See {@link
|
|
149
|
+
* Constructs a CLI instance. See {@link InternalCLI} for more information.
|
|
112
150
|
* @param name Name for the top level CLI
|
|
113
|
-
* @
|
|
151
|
+
* @param rootCommandConfiguration Configuration used when running the bare CLI. e.g. npx my-cli, rather than npx my-cli [cmd]
|
|
152
|
+
* @returns A {@link InternalCLI} instance.
|
|
114
153
|
*/
|
|
115
|
-
export declare function cli(name: string): CLI<
|
|
154
|
+
export declare function cli<TArgs extends ParsedArgs>(name: string, rootCommandConfiguration?: CLICommandOptions<ParsedArgs, TArgs>): CLI<TArgs>;
|
|
116
155
|
export default cli;
|
package/src/lib/cli-forge.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.InternalCLI = void 0;
|
|
4
4
|
exports.cli = cli;
|
|
5
5
|
const parser_1 = require("@cli-forge/parser");
|
|
6
6
|
/**
|
|
@@ -22,20 +22,20 @@ const parser_1 = require("@cli-forge/parser");
|
|
|
22
22
|
* }).forge();
|
|
23
23
|
* ```
|
|
24
24
|
*/
|
|
25
|
-
class
|
|
25
|
+
class InternalCLI {
|
|
26
26
|
name;
|
|
27
|
-
|
|
28
|
-
commands = {};
|
|
27
|
+
registeredCommands = {};
|
|
29
28
|
commandChain = [];
|
|
30
29
|
requiresCommand = false;
|
|
30
|
+
_configuration;
|
|
31
31
|
parser = new parser_1.ArgvParser({
|
|
32
32
|
unmatchedParser: (arg) => {
|
|
33
33
|
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
34
34
|
let currentCommand = this;
|
|
35
35
|
for (const command of this.commandChain) {
|
|
36
|
-
currentCommand = currentCommand.
|
|
36
|
+
currentCommand = currentCommand.registeredCommands[command];
|
|
37
37
|
}
|
|
38
|
-
const command = currentCommand.
|
|
38
|
+
const command = currentCommand.registeredCommands[arg];
|
|
39
39
|
if (command && command.configuration) {
|
|
40
40
|
command.configuration.builder?.(command);
|
|
41
41
|
this.commandChain.push(arg);
|
|
@@ -52,57 +52,70 @@ class CLI {
|
|
|
52
52
|
* @param name What should the name of the cli command be?
|
|
53
53
|
* @param configuration Configuration for the current CLI command.
|
|
54
54
|
*/
|
|
55
|
-
constructor(name
|
|
55
|
+
constructor(name) {
|
|
56
56
|
this.name = name;
|
|
57
|
+
}
|
|
58
|
+
get configuration() {
|
|
59
|
+
return this._configuration;
|
|
60
|
+
}
|
|
61
|
+
set configuration(value) {
|
|
62
|
+
this._configuration = value;
|
|
63
|
+
}
|
|
64
|
+
withRootCommandConfiguration(configuration) {
|
|
57
65
|
this.configuration = configuration;
|
|
66
|
+
return this;
|
|
58
67
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
68
|
+
command(keyOrCommand, options) {
|
|
69
|
+
if (typeof keyOrCommand === 'string') {
|
|
70
|
+
const key = keyOrCommand;
|
|
71
|
+
if (!options) {
|
|
72
|
+
throw new Error('options must be provided when calling `command` with a string');
|
|
73
|
+
}
|
|
74
|
+
if (key === '$0') {
|
|
75
|
+
this.configuration = {
|
|
76
|
+
...this.configuration,
|
|
77
|
+
builder: options.builder,
|
|
78
|
+
handler: options.handler,
|
|
79
|
+
description: options.description,
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
this.registeredCommands[key] = new InternalCLI(key).withRootCommandConfiguration(options);
|
|
83
|
+
this.registeredCommands[key].parser = this.parser;
|
|
84
|
+
}
|
|
85
|
+
else if (keyOrCommand instanceof InternalCLI) {
|
|
86
|
+
const cmd = keyOrCommand;
|
|
87
|
+
this.registeredCommands[cmd.name] = cmd;
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
const { name, ...configuration } = keyOrCommand;
|
|
91
|
+
this.command(name, configuration);
|
|
92
|
+
}
|
|
93
|
+
return this;
|
|
94
|
+
}
|
|
95
|
+
commands(...a0) {
|
|
96
|
+
const commands = a0.flat();
|
|
97
|
+
for (const val of commands) {
|
|
98
|
+
if (val instanceof InternalCLI) {
|
|
99
|
+
this.registeredCommands[val.name] = val;
|
|
100
|
+
// Include any options that were defined via cli(...).option() instead of via builder
|
|
101
|
+
this.parser.augment(val.parser);
|
|
102
|
+
val.parser = this.parser;
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
const { name, ...configuration } = val;
|
|
106
|
+
this.command(name, configuration);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
76
109
|
return this;
|
|
77
110
|
}
|
|
78
|
-
/**
|
|
79
|
-
* Registers a new option for the CLI command. This option will be accessible
|
|
80
|
-
* within the command handler, as well as any subcommands.
|
|
81
|
-
*
|
|
82
|
-
* @param name The name of the option.
|
|
83
|
-
* @param config Configuration for the option. See {@link OptionConfig}.
|
|
84
|
-
* @returns Updated CLI instance with the new option registered.
|
|
85
|
-
*/
|
|
86
111
|
option(name, config) {
|
|
87
112
|
this.parser.option(name, config);
|
|
88
113
|
return this;
|
|
89
114
|
}
|
|
90
|
-
/**
|
|
91
|
-
* Registers a new positional argument for the CLI command. This argument will be accessible
|
|
92
|
-
* within the command handler, as well as any subcommands.
|
|
93
|
-
* @param name The name of the positional argument.
|
|
94
|
-
* @param config Configuration for the positional argument. See {@link OptionConfig}.
|
|
95
|
-
* @returns Updated CLI instance with the new positional argument registered.
|
|
96
|
-
*/
|
|
97
115
|
positional(name, config) {
|
|
98
116
|
this.parser.positional(name, config);
|
|
99
117
|
return this;
|
|
100
118
|
}
|
|
101
|
-
/**
|
|
102
|
-
* Requires a command to be provided when executing the CLI. Useful if your parent command
|
|
103
|
-
* cannot be executed on its own.
|
|
104
|
-
* @returns Updated CLI instance.
|
|
105
|
-
*/
|
|
106
119
|
demandCommand() {
|
|
107
120
|
this.requiresCommand = true;
|
|
108
121
|
return this;
|
|
@@ -116,7 +129,7 @@ class CLI {
|
|
|
116
129
|
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
117
130
|
let command = this;
|
|
118
131
|
for (const key of this.commandChain) {
|
|
119
|
-
command = command.
|
|
132
|
+
command = command.registeredCommands[key];
|
|
120
133
|
}
|
|
121
134
|
help.push(`Usage: ${[
|
|
122
135
|
this.name,
|
|
@@ -126,12 +139,12 @@ class CLI {
|
|
|
126
139
|
if (command.configuration?.description) {
|
|
127
140
|
help.push(command.configuration.description);
|
|
128
141
|
}
|
|
129
|
-
if (Object.keys(command.
|
|
142
|
+
if (Object.keys(command.registeredCommands).length > 0) {
|
|
130
143
|
help.push('');
|
|
131
144
|
help.push('Commands:');
|
|
132
145
|
}
|
|
133
|
-
for (const key in command.
|
|
134
|
-
const subcommand = command.
|
|
146
|
+
for (const key in command.registeredCommands) {
|
|
147
|
+
const subcommand = command.registeredCommands[key];
|
|
135
148
|
help.push(` ${key}${subcommand.configuration?.description
|
|
136
149
|
? ' - ' + subcommand.configuration.description
|
|
137
150
|
: ''}`);
|
|
@@ -144,7 +157,7 @@ class CLI {
|
|
|
144
157
|
const option = this.parser.configuredOptions[key];
|
|
145
158
|
help.push(` --${key}${option.description ? ' - ' + option.description : ''}`);
|
|
146
159
|
}
|
|
147
|
-
if (Object.keys(command.
|
|
160
|
+
if (Object.keys(command.registeredCommands).length > 0) {
|
|
148
161
|
help.push(' ');
|
|
149
162
|
help.push(`Run \`${[this.name, ...this.commandChain].join(' ')} [command] --help\` for more information on a command`);
|
|
150
163
|
}
|
|
@@ -167,7 +180,9 @@ class CLI {
|
|
|
167
180
|
throw new Error(`${[this.name, ...this.commandChain].join(' ')} requires a command`);
|
|
168
181
|
}
|
|
169
182
|
if (cmd.configuration?.handler) {
|
|
170
|
-
await cmd.configuration.handler(args
|
|
183
|
+
await cmd.configuration.handler(args, {
|
|
184
|
+
command: cmd,
|
|
185
|
+
});
|
|
171
186
|
}
|
|
172
187
|
else {
|
|
173
188
|
throw new Error(`${[this.name, ...this.commandChain].join(' ')} is not implemented.`);
|
|
@@ -192,14 +207,15 @@ class CLI {
|
|
|
192
207
|
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
193
208
|
let currentCommand = this;
|
|
194
209
|
for (const command of this.commandChain) {
|
|
195
|
-
currentCommand = currentCommand.
|
|
210
|
+
currentCommand = currentCommand.registeredCommands[command];
|
|
196
211
|
}
|
|
197
212
|
if (argv.help) {
|
|
198
213
|
this.printHelp();
|
|
199
214
|
return;
|
|
200
215
|
}
|
|
201
216
|
const finalArgV = currentCommand === this
|
|
202
|
-
? (this.configuration?.builder?.(this)
|
|
217
|
+
? (this.configuration?.builder?.(this)
|
|
218
|
+
?.parser ?? this.parser).parse(args)
|
|
203
219
|
: argv;
|
|
204
220
|
await this.runCommand(currentCommand, finalArgV);
|
|
205
221
|
}
|
|
@@ -207,25 +223,33 @@ class CLI {
|
|
|
207
223
|
return this.parser.asReadonly();
|
|
208
224
|
}
|
|
209
225
|
getSubcommands() {
|
|
210
|
-
return this.
|
|
226
|
+
return this.registeredCommands;
|
|
211
227
|
}
|
|
212
228
|
clone() {
|
|
213
|
-
const clone = new
|
|
214
|
-
|
|
229
|
+
const clone = new InternalCLI(this.name);
|
|
230
|
+
if (this.configuration) {
|
|
231
|
+
clone.withRootCommandConfiguration(this.configuration);
|
|
232
|
+
}
|
|
233
|
+
clone.registeredCommands = { ...this.registeredCommands };
|
|
215
234
|
clone.commandChain = [...this.commandChain];
|
|
216
235
|
clone.requiresCommand = this.requiresCommand;
|
|
217
236
|
clone.parser = this.parser.clone();
|
|
218
237
|
return clone;
|
|
219
238
|
}
|
|
220
239
|
}
|
|
221
|
-
exports.
|
|
240
|
+
exports.InternalCLI = InternalCLI;
|
|
222
241
|
/**
|
|
223
|
-
* Constructs a CLI instance. See {@link
|
|
242
|
+
* Constructs a CLI instance. See {@link InternalCLI} for more information.
|
|
224
243
|
* @param name Name for the top level CLI
|
|
225
|
-
* @
|
|
244
|
+
* @param rootCommandConfiguration Configuration used when running the bare CLI. e.g. npx my-cli, rather than npx my-cli [cmd]
|
|
245
|
+
* @returns A {@link InternalCLI} instance.
|
|
226
246
|
*/
|
|
227
|
-
function cli(name) {
|
|
228
|
-
|
|
247
|
+
function cli(name, rootCommandConfiguration) {
|
|
248
|
+
const cli = new InternalCLI(name);
|
|
249
|
+
if (rootCommandConfiguration) {
|
|
250
|
+
cli.withRootCommandConfiguration(rootCommandConfiguration);
|
|
251
|
+
}
|
|
252
|
+
return cli;
|
|
229
253
|
}
|
|
230
254
|
exports.default = cli;
|
|
231
255
|
//# sourceMappingURL=cli-forge.js.map
|
package/src/lib/cli-forge.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli-forge.js","sourceRoot":"","sources":["../../../../../packages/cli-forge/src/lib/cli-forge.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"cli-forge.js","sourceRoot":"","sources":["../../../../../packages/cli-forge/src/lib/cli-forge.ts"],"names":[],"mappings":";;;AA2bA,kBAWC;AAtcD,8CAK2B;AAkI3B;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAa,WAAW;IAkCH;IA/BX,kBAAkB,GAAqC,EAAE,CAAC;IAC1D,YAAY,GAAa,EAAE,CAAC;IAC5B,eAAe,GAAG,KAAK,CAAC;IAExB,cAAc,CAA+B;IAE7C,MAAM,GAAG,IAAI,mBAAU,CAAQ;QACrC,eAAe,EAAE,CAAC,GAAG,EAAE,EAAE;YACvB,4DAA4D;YAC5D,IAAI,cAAc,GAAqB,IAAI,CAAC;YAC5C,KAAK,MAAM,OAAO,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;gBACxC,cAAc,GAAG,cAAc,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC;YAC9D,CAAC;YACD,MAAM,OAAO,GAAG,cAAc,CAAC,kBAAkB,CAAC,GAAG,CAAC,CAAC;YACvD,IAAI,OAAO,IAAI,OAAO,CAAC,aAAa,EAAE,CAAC;gBACrC,OAAO,CAAC,aAAa,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,CAAC;gBACzC,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;gBAC5B,OAAO,IAAI,CAAC;YACd,CAAC;YACD,OAAO,KAAK,CAAC;QACf,CAAC;KACF,CAAC,CAAC,MAAM,CAAC,MAAM,EAAE;QAChB,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;YACf,CAAC,CAAC,IAAI,CAAC;QAEX,MAAM,IAAI,CAAC,UAAU,CAAC,cAAc,EAAE,SAAS,CAAC,CAAC;IACnD,CAAC;IAED,SAAS;QACP,OAAO,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC;IAClC,CAAC;IAED,cAAc;QACZ,OAAO,IAAI,CAAC,kBAA2D,CAAC;IAC1E,CAAC;IAED,KAAK;QACH,MAAM,KAAK,GAAG,IAAI,WAAW,CAAQ,IAAI,CAAC,IAAI,CAAC,CAAC;QAChD,IAAI,IAAI,CAAC,aAAa,EAAE,CAAC;YACvB,KAAK,CAAC,4BAA4B,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QACzD,CAAC;QACD,KAAK,CAAC,kBAAkB,GAAG,EAAE,GAAG,IAAI,CAAC,kBAAkB,EAAE,CAAC;QAC1D,KAAK,CAAC,YAAY,GAAG,CAAC,GAAG,IAAI,CAAC,YAAY,CAAC,CAAC;QAC5C,KAAK,CAAC,eAAe,GAAG,IAAI,CAAC,eAAe,CAAC;QAC7C,KAAK,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,EAAS,CAAC;QAC1C,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AAzRD,kCAyRC;AAED;;;;;GAKG;AACH,SAAgB,GAAG,CACjB,IAAY,EACZ,wBAA+D;IAE/D,MAAM,GAAG,GAAG,IAAI,WAAW,CAAC,IAAI,CAAC,CAAC;IAElC,IAAI,wBAAwB,EAAE,CAAC;QAC7B,GAAG,CAAC,4BAA4B,CAAC,wBAAwB,CAAC,CAAC;IAC7D,CAAC;IAED,OAAO,GAAiB,CAAC;AAC3B,CAAC;AAED,kBAAe,GAAG,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { OptionConfig } from '@cli-forge/parser';
|
|
2
|
-
import {
|
|
2
|
+
import { InternalCLI } from './cli-forge';
|
|
3
3
|
export type Documentation = {
|
|
4
4
|
name: string;
|
|
5
5
|
description?: string;
|
|
@@ -11,7 +11,7 @@ export type Documentation = {
|
|
|
11
11
|
}>[];
|
|
12
12
|
subcommands: Documentation[];
|
|
13
13
|
};
|
|
14
|
-
export declare function generateDocumentation(cli:
|
|
14
|
+
export declare function generateDocumentation(cli: InternalCLI): {
|
|
15
15
|
name: string;
|
|
16
16
|
description: string | undefined;
|
|
17
17
|
options: Readonly<{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"documentation.js","sourceRoot":"","sources":["../../../../../packages/cli-forge/src/lib/documentation.ts"],"names":[],"mappings":";;AAWA,sDAoBC;AApBD,SAAgB,qBAAqB,CAAC,
|
|
1
|
+
{"version":3,"file":"documentation.js","sourceRoot":"","sources":["../../../../../packages/cli-forge/src/lib/documentation.ts"],"names":[],"mappings":";;AAWA,sDAoBC;AApBD,SAAgB,qBAAqB,CAAC,GAAgB;IACpD,8CAA8C;IAC9C,IAAI,GAAG,CAAC,aAAa,EAAE,OAAO,EAAE,CAAC;QAC/B,GAAG,CAAC,aAAa,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IACjC,CAAC;IACD,MAAM,MAAM,GAAG,GAAG,CAAC,SAAS,EAAE,CAAC;IAE/B,MAAM,OAAO,GAAG,MAAM,CAAC,iBAAiB,CAAC;IACzC,MAAM,WAAW,GAAG,MAAM,CAAC,qBAAqB,CAAC;IACjD,MAAM,WAAW,GAAoB,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,cAAc,EAAE,CAAC,CAAC,GAAG,CAC1E,CAAC,GAAG,EAAE,EAAE,CAAC,qBAAqB,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC,CAC5C,CAAC;IAEF,OAAO;QACL,IAAI,EAAE,GAAG,CAAC,IAAI;QACd,WAAW,EAAE,GAAG,CAAC,aAAa,EAAE,WAAW;QAC3C,OAAO;QACP,WAAW;QACX,WAAW;KACZ,CAAC;AACJ,CAAC"}
|