@clerc/plugin-help 0.13.2 → 0.14.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.d.ts +6 -1
- package/dist/index.js +7 -6
- package/dist/index.mjs +7 -6
- package/package.json +4 -4
package/dist/index.d.ts
CHANGED
|
@@ -7,6 +7,11 @@ interface HelpPluginOptions {
|
|
|
7
7
|
* @default true
|
|
8
8
|
*/
|
|
9
9
|
command?: boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Whether to show help when no command is specified.
|
|
12
|
+
* @default true
|
|
13
|
+
*/
|
|
14
|
+
showHelpWhenNoCommand?: boolean;
|
|
10
15
|
/**
|
|
11
16
|
* Global notes.
|
|
12
17
|
*/
|
|
@@ -16,6 +21,6 @@ interface HelpPluginOptions {
|
|
|
16
21
|
*/
|
|
17
22
|
examples?: [string, string][];
|
|
18
23
|
}
|
|
19
|
-
declare const helpPlugin: ({ command, notes, examples, }?: HelpPluginOptions) => _clerc_core.Plugin<Clerc<{}>, Clerc<{}>>;
|
|
24
|
+
declare const helpPlugin: ({ command, showHelpWhenNoCommand, notes, examples, }?: HelpPluginOptions) => _clerc_core.Plugin<Clerc<{}>, Clerc<{}>>;
|
|
20
25
|
|
|
21
26
|
export { HelpPluginOptions, helpPlugin };
|
package/dist/index.js
CHANGED
|
@@ -52,17 +52,17 @@ const formatCommandName = (name) => Array.isArray(name) ? name.join(" ") : typeo
|
|
|
52
52
|
const generateCliDetail = (sections, cli, subcommand) => {
|
|
53
53
|
const items = [
|
|
54
54
|
{
|
|
55
|
-
title:
|
|
55
|
+
title: "Name:",
|
|
56
56
|
body: pc.red(cli._name)
|
|
57
57
|
},
|
|
58
58
|
{
|
|
59
|
-
title:
|
|
59
|
+
title: "Version:",
|
|
60
60
|
body: pc.yellow(cli._version)
|
|
61
61
|
}
|
|
62
62
|
];
|
|
63
63
|
if (subcommand) {
|
|
64
64
|
items.push({
|
|
65
|
-
title:
|
|
65
|
+
title: "Subcommand:",
|
|
66
66
|
body: pc.green(formatCommandName(subcommand.name))
|
|
67
67
|
});
|
|
68
68
|
}
|
|
@@ -89,12 +89,12 @@ const showHelp = (ctx, notes, examples) => {
|
|
|
89
89
|
if (ctx.isSingleCommand) {
|
|
90
90
|
sections.push({
|
|
91
91
|
title: "Usage:",
|
|
92
|
-
body: [`$ ${cli._name} [flags]`]
|
|
92
|
+
body: [pc.magenta(`$ ${cli._name} [flags]`)]
|
|
93
93
|
});
|
|
94
94
|
} else {
|
|
95
95
|
sections.push({
|
|
96
96
|
title: "Usage:",
|
|
97
|
-
body: [`$ ${cli._name} [command] [flags]`]
|
|
97
|
+
body: [pc.magenta(`$ ${cli._name} [command] [flags]`)]
|
|
98
98
|
});
|
|
99
99
|
}
|
|
100
100
|
if (!ctx.isSingleCommand) {
|
|
@@ -164,6 +164,7 @@ const showSubcommandHelp = (ctx, command) => {
|
|
|
164
164
|
};
|
|
165
165
|
const helpPlugin = ({
|
|
166
166
|
command = true,
|
|
167
|
+
showHelpWhenNoCommand = true,
|
|
167
168
|
notes,
|
|
168
169
|
examples
|
|
169
170
|
} = {}) => definePlugin({
|
|
@@ -192,7 +193,7 @@ const helpPlugin = ({
|
|
|
192
193
|
});
|
|
193
194
|
}
|
|
194
195
|
cli.inspector((ctx, next) => {
|
|
195
|
-
if (!ctx.isSingleCommand && !ctx.raw._.length) {
|
|
196
|
+
if (!ctx.isSingleCommand && !ctx.raw._.length && showHelpWhenNoCommand) {
|
|
196
197
|
showHelp(ctx, notes, examples);
|
|
197
198
|
} else if (ctx.raw.mergedFlags.h || ctx.raw.mergedFlags.help) {
|
|
198
199
|
if (ctx.raw._.length) {
|
package/dist/index.mjs
CHANGED
|
@@ -52,17 +52,17 @@ const formatCommandName = (name) => Array.isArray(name) ? name.join(" ") : typeo
|
|
|
52
52
|
const generateCliDetail = (sections, cli, subcommand) => {
|
|
53
53
|
const items = [
|
|
54
54
|
{
|
|
55
|
-
title:
|
|
55
|
+
title: "Name:",
|
|
56
56
|
body: pc.red(cli._name)
|
|
57
57
|
},
|
|
58
58
|
{
|
|
59
|
-
title:
|
|
59
|
+
title: "Version:",
|
|
60
60
|
body: pc.yellow(cli._version)
|
|
61
61
|
}
|
|
62
62
|
];
|
|
63
63
|
if (subcommand) {
|
|
64
64
|
items.push({
|
|
65
|
-
title:
|
|
65
|
+
title: "Subcommand:",
|
|
66
66
|
body: pc.green(formatCommandName(subcommand.name))
|
|
67
67
|
});
|
|
68
68
|
}
|
|
@@ -89,12 +89,12 @@ const showHelp = (ctx, notes, examples) => {
|
|
|
89
89
|
if (ctx.isSingleCommand) {
|
|
90
90
|
sections.push({
|
|
91
91
|
title: "Usage:",
|
|
92
|
-
body: [`$ ${cli._name} [flags]`]
|
|
92
|
+
body: [pc.magenta(`$ ${cli._name} [flags]`)]
|
|
93
93
|
});
|
|
94
94
|
} else {
|
|
95
95
|
sections.push({
|
|
96
96
|
title: "Usage:",
|
|
97
|
-
body: [`$ ${cli._name} [command] [flags]`]
|
|
97
|
+
body: [pc.magenta(`$ ${cli._name} [command] [flags]`)]
|
|
98
98
|
});
|
|
99
99
|
}
|
|
100
100
|
if (!ctx.isSingleCommand) {
|
|
@@ -164,6 +164,7 @@ const showSubcommandHelp = (ctx, command) => {
|
|
|
164
164
|
};
|
|
165
165
|
const helpPlugin = ({
|
|
166
166
|
command = true,
|
|
167
|
+
showHelpWhenNoCommand = true,
|
|
167
168
|
notes,
|
|
168
169
|
examples
|
|
169
170
|
} = {}) => definePlugin({
|
|
@@ -192,7 +193,7 @@ const helpPlugin = ({
|
|
|
192
193
|
});
|
|
193
194
|
}
|
|
194
195
|
cli.inspector((ctx, next) => {
|
|
195
|
-
if (!ctx.isSingleCommand && !ctx.raw._.length) {
|
|
196
|
+
if (!ctx.isSingleCommand && !ctx.raw._.length && showHelpWhenNoCommand) {
|
|
196
197
|
showHelp(ctx, notes, examples);
|
|
197
198
|
} else if (ctx.raw.mergedFlags.h || ctx.raw.mergedFlags.help) {
|
|
198
199
|
if (ctx.raw._.length) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@clerc/plugin-help",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.0",
|
|
4
4
|
"author": "Ray <nn_201312@163.com> (https://github.com/so1ve)",
|
|
5
5
|
"description": "Clerc plugin help",
|
|
6
6
|
"keywords": [
|
|
@@ -52,11 +52,11 @@
|
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
54
|
"picocolors": "^1.0.0",
|
|
55
|
-
"@clerc/toolkit": "0.
|
|
56
|
-
"@clerc/utils": "0.
|
|
55
|
+
"@clerc/toolkit": "0.14.0",
|
|
56
|
+
"@clerc/utils": "0.14.0"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
|
-
"@clerc/core": "0.
|
|
59
|
+
"@clerc/core": "0.14.0"
|
|
60
60
|
},
|
|
61
61
|
"scripts": {
|
|
62
62
|
"build": "puild",
|