@clerc/plugin-help 1.0.3 → 1.1.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/README.md +2 -16
- package/dist/{index.d.ts → index.d.mts} +16 -19
- package/dist/{index.js → index.mjs} +1 -1
- package/package.json +9 -16
package/README.md
CHANGED
|
@@ -2,23 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.com/package/@clerc/plugin-help)
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
## Documenation
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
```bash
|
|
10
|
-
$ npm install @clerc/plugin-help
|
|
11
|
-
$ yarn add @clerc/plugin-help
|
|
12
|
-
$ pnpm add @clerc/plugin-help
|
|
13
|
-
```
|
|
14
|
-
|
|
15
|
-
## 🚀 Usage
|
|
16
|
-
|
|
17
|
-
```ts
|
|
18
|
-
import { helpPlugin } from "@clerc/plugin-help";
|
|
19
|
-
|
|
20
|
-
cli.use(helpPlugin());
|
|
21
|
-
```
|
|
7
|
+
Read the [documentation](https://clerc.so1ve.dev/official-plugins/plugin-help.html) for more details.
|
|
22
8
|
|
|
23
9
|
## 📝 License
|
|
24
10
|
|
|
@@ -7,9 +7,9 @@ interface Formatters {
|
|
|
7
7
|
formatFlagDefault: <T>(value: FlagDefaultValue<T>) => string;
|
|
8
8
|
}
|
|
9
9
|
/**
|
|
10
|
-
* A group definition as a tuple of [key, displayName].
|
|
11
|
-
*
|
|
12
|
-
*
|
|
10
|
+
* A group definition as a tuple of [key, displayName]. The key is used in help
|
|
11
|
+
* options to assign items to groups. The displayName is shown in the help
|
|
12
|
+
* output.
|
|
13
13
|
*/
|
|
14
14
|
type GroupDefinition = [key: string, name: string];
|
|
15
15
|
/**
|
|
@@ -17,18 +17,15 @@ type GroupDefinition = [key: string, name: string];
|
|
|
17
17
|
*/
|
|
18
18
|
interface GroupsOptions {
|
|
19
19
|
/**
|
|
20
|
-
* Groups for commands.
|
|
21
|
-
* Each group is defined as `[key, name]`.
|
|
20
|
+
* Groups for commands. Each group is defined as `[key, name]`.
|
|
22
21
|
*/
|
|
23
22
|
commands?: GroupDefinition[];
|
|
24
23
|
/**
|
|
25
|
-
* Groups for command-specific flags.
|
|
26
|
-
* Each group is defined as `[key, name]`.
|
|
24
|
+
* Groups for command-specific flags. Each group is defined as `[key, name]`.
|
|
27
25
|
*/
|
|
28
26
|
flags?: GroupDefinition[];
|
|
29
27
|
/**
|
|
30
|
-
* Groups for global flags.
|
|
31
|
-
* Each group is defined as `[key, name]`.
|
|
28
|
+
* Groups for global flags. Each group is defined as `[key, name]`.
|
|
32
29
|
*/
|
|
33
30
|
globalFlags?: GroupDefinition[];
|
|
34
31
|
}
|
|
@@ -39,8 +36,8 @@ declare const defaultFormatters: Formatters;
|
|
|
39
36
|
//#region src/index.d.ts
|
|
40
37
|
interface HelpOptions {
|
|
41
38
|
/**
|
|
42
|
-
* The group this item belongs to.
|
|
43
|
-
*
|
|
39
|
+
* The group this item belongs to. The group must be defined in the `groups`
|
|
40
|
+
* option of `helpPlugin()`.
|
|
44
41
|
*/
|
|
45
42
|
group?: string;
|
|
46
43
|
}
|
|
@@ -56,8 +53,8 @@ interface CommandHelpOptions extends HelpOptions {
|
|
|
56
53
|
*/
|
|
57
54
|
notes?: string[];
|
|
58
55
|
/**
|
|
59
|
-
* Examples to show in the help output.
|
|
60
|
-
*
|
|
56
|
+
* Examples to show in the help output. Each example is a tuple of `[command,
|
|
57
|
+
* description]`.
|
|
61
58
|
*/
|
|
62
59
|
examples?: [string, string][];
|
|
63
60
|
}
|
|
@@ -99,8 +96,8 @@ interface HelpPluginOptions {
|
|
|
99
96
|
*/
|
|
100
97
|
notes?: string[];
|
|
101
98
|
/**
|
|
102
|
-
* Examples to show in the help output.
|
|
103
|
-
*
|
|
99
|
+
* Examples to show in the help output. Each example is a tuple of `[command,
|
|
100
|
+
* description]`.
|
|
104
101
|
*/
|
|
105
102
|
examples?: [string, string][];
|
|
106
103
|
/**
|
|
@@ -116,10 +113,10 @@ interface HelpPluginOptions {
|
|
|
116
113
|
*/
|
|
117
114
|
formatters?: Partial<Formatters>;
|
|
118
115
|
/**
|
|
119
|
-
* Group definitions for commands and flags.
|
|
120
|
-
*
|
|
121
|
-
*
|
|
122
|
-
*
|
|
116
|
+
* Group definitions for commands and flags. Groups allow organizing commands
|
|
117
|
+
* and flags into logical sections in help output. Each group is defined as
|
|
118
|
+
* `[key, name]` where `key` is the identifier used in help options and `name`
|
|
119
|
+
* is the display name shown in help output.
|
|
123
120
|
*/
|
|
124
121
|
groups?: GroupsOptions;
|
|
125
122
|
}
|
|
@@ -114,7 +114,7 @@ var HelpRenderer = class {
|
|
|
114
114
|
});
|
|
115
115
|
usage += ` ${items.join(" ")}`;
|
|
116
116
|
}
|
|
117
|
-
} else if (this._cli._commands.size > 0 && !
|
|
117
|
+
} else if (this._cli._commands.size > 0 && (!this._cli._commands.has("") || this._cli._commands.size !== 1)) usage += this._cli._commands.has("") ? ` ${tint.dim("[command]")}` : ` ${tint.dim("<command>")}`;
|
|
118
118
|
if (command?.flags && !objectIsEmpty(command.flags) || !objectIsEmpty(this._globalFlags)) usage += ` ${tint.dim("[flags]")}`;
|
|
119
119
|
return {
|
|
120
120
|
title: "Usage",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@clerc/plugin-help",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"author": "Ray <i@mk1.io> (https://github.com/so1ve)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "Clerc plugin help",
|
|
@@ -25,19 +25,12 @@
|
|
|
25
25
|
"license": "MIT",
|
|
26
26
|
"sideEffects": false,
|
|
27
27
|
"exports": {
|
|
28
|
-
".": "./dist/index.
|
|
29
|
-
|
|
30
|
-
"main": "./dist/index.js",
|
|
31
|
-
"module": "./dist/index.js",
|
|
32
|
-
"types": "dist/index.d.ts",
|
|
33
|
-
"typesVersions": {
|
|
34
|
-
"*": {
|
|
35
|
-
"*": [
|
|
36
|
-
"./dist/*",
|
|
37
|
-
"./dist/index.d.ts"
|
|
38
|
-
]
|
|
39
|
-
}
|
|
28
|
+
".": "./dist/index.mjs",
|
|
29
|
+
"./package.json": "./package.json"
|
|
40
30
|
},
|
|
31
|
+
"main": "./dist/index.mjs",
|
|
32
|
+
"module": "./dist/index.mjs",
|
|
33
|
+
"types": "./dist/index.d.mts",
|
|
41
34
|
"files": [
|
|
42
35
|
"dist"
|
|
43
36
|
],
|
|
@@ -48,13 +41,13 @@
|
|
|
48
41
|
"@uttr/tint": "^0.1.3",
|
|
49
42
|
"string-width": "^8.1.0",
|
|
50
43
|
"text-table": "^0.2.0",
|
|
51
|
-
"@clerc/utils": "1.0
|
|
44
|
+
"@clerc/utils": "1.1.0"
|
|
52
45
|
},
|
|
53
46
|
"devDependencies": {
|
|
54
47
|
"@types/text-table": "^0.2.5",
|
|
55
48
|
"kons": "^0.7.1",
|
|
56
|
-
"@clerc/
|
|
57
|
-
"@clerc/
|
|
49
|
+
"@clerc/parser": "1.1.0",
|
|
50
|
+
"@clerc/core": "1.1.0"
|
|
58
51
|
},
|
|
59
52
|
"peerDependencies": {
|
|
60
53
|
"@clerc/core": "*"
|