@clerc/plugin-help 0.9.2 → 0.10.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/dist/index.cjs +6 -6
- package/dist/index.d.ts +3 -3
- package/dist/index.mjs +1 -1
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var core = require('@clerc/core');
|
|
6
6
|
var utils = require('@clerc/utils');
|
|
7
7
|
var pc = require('picocolors');
|
|
8
8
|
|
|
@@ -47,7 +47,7 @@ const defaultOptions = {
|
|
|
47
47
|
examples: [],
|
|
48
48
|
notes: []
|
|
49
49
|
};
|
|
50
|
-
const helpPlugin = (_options) =>
|
|
50
|
+
const helpPlugin = (_options) => core.definePlugin({
|
|
51
51
|
setup(cli) {
|
|
52
52
|
const { command, ...rest } = { ...defaultOptions, ..._options };
|
|
53
53
|
cli.inspector((inspectorCtx, next) => {
|
|
@@ -103,7 +103,7 @@ function showHelp(ctx, { examples, notes }) {
|
|
|
103
103
|
console.log(` ${cli._name || "<CLI NAME>"} <SUBCOMMAND> [OPTIONS]`);
|
|
104
104
|
newline();
|
|
105
105
|
console.log(pc__default["default"].yellow("COMMANDS:"));
|
|
106
|
-
const commandNameAndAlias = generateNameAndAliasFromCommands(utils.generateCommandRecordFromCommandArray(
|
|
106
|
+
const commandNameAndAlias = generateNameAndAliasFromCommands(utils.generateCommandRecordFromCommandArray(core.resolveRootCommands(cli._commands)));
|
|
107
107
|
const commandsPadLength = getPadLength(Object.values(commandNameAndAlias));
|
|
108
108
|
for (const [name, nameAndAlias] of Object.entries(commandNameAndAlias)) {
|
|
109
109
|
console.log(` ${pc__default["default"].green(nameAndAlias.padEnd(commandsPadLength))}${cli._commands[name].description}`);
|
|
@@ -140,9 +140,9 @@ function showCommandNotes(notes) {
|
|
|
140
140
|
function showSubcommandHelp(ctx) {
|
|
141
141
|
const { cli } = ctx;
|
|
142
142
|
const commandName = ctx.parameters.command;
|
|
143
|
-
const commandToShowHelp =
|
|
143
|
+
const commandToShowHelp = core.resolveCommand(cli._commands, commandName);
|
|
144
144
|
if (!commandToShowHelp) {
|
|
145
|
-
throw new
|
|
145
|
+
throw new core.NoSuchCommandError(commandName.join(" "));
|
|
146
146
|
}
|
|
147
147
|
console.log(`${pc__default["default"].green(`${cli._name} ${commandToShowHelp.name}`)} ${utils.gracefulVersion(cli._version)}`);
|
|
148
148
|
commandToShowHelp.description && console.log(commandToShowHelp.description);
|
|
@@ -163,7 +163,7 @@ function showSubcommandHelp(ctx) {
|
|
|
163
163
|
}
|
|
164
164
|
function showSingleCommandHelp(ctx) {
|
|
165
165
|
const { cli } = ctx;
|
|
166
|
-
const singleCommand = cli._commands[
|
|
166
|
+
const singleCommand = cli._commands[core.SingleCommand];
|
|
167
167
|
console.log(`${pc__default["default"].green(`${cli._name} ${utils.gracefulVersion(cli._version)}`)}`);
|
|
168
168
|
singleCommand.description && console.log(singleCommand.description);
|
|
169
169
|
newline();
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import { Clerc } from 'clerc';
|
|
1
|
+
import * as _clerc_core from '@clerc/core';
|
|
2
|
+
import { Clerc } from '@clerc/core';
|
|
3
3
|
|
|
4
4
|
interface Options {
|
|
5
5
|
/**
|
|
@@ -16,6 +16,6 @@ interface Options {
|
|
|
16
16
|
*/
|
|
17
17
|
notes?: string[];
|
|
18
18
|
}
|
|
19
|
-
declare const helpPlugin: (_options?: Options) =>
|
|
19
|
+
declare const helpPlugin: (_options?: Options) => _clerc_core.Plugin<Clerc<{}>, Clerc<{}>>;
|
|
20
20
|
|
|
21
21
|
export { helpPlugin };
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { definePlugin, resolveRootCommands, resolveCommand, NoSuchCommandError, SingleCommand } from 'clerc';
|
|
1
|
+
import { definePlugin, resolveRootCommands, resolveCommand, NoSuchCommandError, SingleCommand } from '@clerc/core';
|
|
2
2
|
import { mustArray, gracefulFlagName, gracefulVersion, generateCommandRecordFromCommandArray } from '@clerc/utils';
|
|
3
3
|
import pc from 'picocolors';
|
|
4
4
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@clerc/plugin-help",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"author": "Ray <nn_201312@163.com> (https://github.com/so1ve)",
|
|
5
5
|
"description": "Clerc plugin help",
|
|
6
6
|
"keywords": [
|
|
@@ -40,12 +40,12 @@
|
|
|
40
40
|
"access": "public"
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|
|
43
|
-
"clerc": "*"
|
|
43
|
+
"@clerc/core": "*"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
46
|
"picocolors": "^1.0.0",
|
|
47
|
-
"@clerc/utils": "0.
|
|
48
|
-
"clerc": "0.
|
|
47
|
+
"@clerc/utils": "0.10.0",
|
|
48
|
+
"@clerc/core": "0.10.0"
|
|
49
49
|
},
|
|
50
50
|
"scripts": {
|
|
51
51
|
"build": "puild",
|