clerc 1.0.0-beta.2 → 1.0.0-beta.3

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.
Files changed (2) hide show
  1. package/dist/index.d.ts +120 -8
  2. package/package.json +8 -8
package/dist/index.d.ts CHANGED
@@ -2,6 +2,21 @@ import { Plugin } from "@clerc/core";
2
2
  export * from "@clerc/core";
3
3
 
4
4
  //#region ../plugin-completions/src/index.d.ts
5
+ declare module "@clerc/core" {
6
+ interface CommandCustomOptions {
7
+ /**
8
+ * Completions options for the command.
9
+ */
10
+ completions?: {
11
+ /**
12
+ * Whether to show the command in completions output.
13
+ *
14
+ * @default true
15
+ */
16
+ show?: boolean;
17
+ };
18
+ }
19
+ }
5
20
  interface CompletionsPluginOptions {
6
21
  /**
7
22
  * Whether to register the `completions install` and `completions uninstall` commands.
@@ -25,35 +40,131 @@ declare const friendlyErrorPlugin: ({
25
40
  *
26
41
  * @template T The target type.
27
42
  */
28
- type FlagTypeFunction<T = unknown> = (value: string) => T;
43
+ type FlagTypeFunction<T = unknown> = ((value: string) => T) & {
44
+ /**
45
+ * Optional display name for the type, useful in help output.
46
+ * If provided, this will be shown instead of the function name.
47
+ */
48
+ displayName?: string;
49
+ };
29
50
  type FlagType<T = unknown> = FlagTypeFunction<T> | readonly [FlagTypeFunction<T>];
30
51
  //#endregion
31
52
  //#region ../plugin-help/src/types.d.ts
32
53
  interface Formatters {
33
54
  formatFlagType: (type: FlagType) => string;
34
55
  }
56
+ /**
57
+ * A group definition as a tuple of [key, displayName].
58
+ * The key is used in help options to assign items to groups.
59
+ * The displayName is shown in the help output.
60
+ */
61
+ type GroupDefinition = [key: string, name: string];
62
+ /**
63
+ * Options for defining groups in help output.
64
+ */
65
+ interface GroupsOptions {
66
+ /**
67
+ * Groups for commands.
68
+ * Each group is defined as `[key, name]`.
69
+ */
70
+ commands?: GroupDefinition[];
71
+ /**
72
+ * Groups for command-specific flags.
73
+ * Each group is defined as `[key, name]`.
74
+ */
75
+ flags?: GroupDefinition[];
76
+ /**
77
+ * Groups for global flags.
78
+ * Each group is defined as `[key, name]`.
79
+ */
80
+ globalFlags?: GroupDefinition[];
81
+ }
35
82
  //#endregion
36
83
  //#region ../plugin-help/src/formatters.d.ts
37
84
  declare const defaultFormatters: Formatters;
38
85
  //#endregion
39
86
  //#region ../plugin-help/src/index.d.ts
87
+ interface HelpOptions {
88
+ /**
89
+ * The group this item belongs to.
90
+ * The group must be defined in the `groups` option of `helpPlugin()`.
91
+ */
92
+ group?: string;
93
+ }
94
+ interface CommandHelpOptions extends HelpOptions {
95
+ /**
96
+ * Whether to show the command in help output.
97
+ *
98
+ * @default true
99
+ */
100
+ show?: boolean;
101
+ /**
102
+ * Notes to show in the help output.
103
+ */
104
+ notes?: string[];
105
+ /**
106
+ * Examples to show in the help output.
107
+ * Each example is a tuple of `[command, description]`.
108
+ */
109
+ examples?: [string, string][];
110
+ }
40
111
  declare module "@clerc/core" {
41
112
  interface CommandCustomOptions {
42
- help?: {
43
- showInHelp?: boolean;
44
- notes?: string[];
45
- examples?: [string, string][];
46
- };
113
+ /**
114
+ * Help options for the command.
115
+ */
116
+ help?: CommandHelpOptions;
117
+ }
118
+ interface FlagCustomOptions {
119
+ /**
120
+ * Help options for the flag.
121
+ */
122
+ help?: HelpOptions;
47
123
  }
48
124
  }
49
125
  interface HelpPluginOptions {
126
+ /**
127
+ * Whether to register the `help` command.
128
+ *
129
+ * @default true
130
+ */
50
131
  command?: boolean;
132
+ /**
133
+ * Whether to register the `--help` global flag.
134
+ *
135
+ * @default true
136
+ */
51
137
  flag?: boolean;
138
+ /**
139
+ * Whether to show help when no command is specified.
140
+ *
141
+ * @default true
142
+ */
52
143
  showHelpWhenNoCommandSpecified?: boolean;
144
+ /**
145
+ * Notes to show in the help output.
146
+ */
53
147
  notes?: string[];
148
+ /**
149
+ * Examples to show in the help output.
150
+ * Each example is a tuple of `[command, description]`.
151
+ */
54
152
  examples?: [string, string][];
153
+ /**
154
+ * A banner to show before the help output.
155
+ */
55
156
  banner?: string;
157
+ /**
158
+ * Custom formatters for rendering help.
159
+ */
56
160
  formatters?: Partial<Formatters>;
161
+ /**
162
+ * Group definitions for commands and flags.
163
+ * Groups allow organizing commands and flags into logical sections in help output.
164
+ * Each group is defined as `[key, name]` where `key` is the identifier used in help options
165
+ * and `name` is the display name shown in help output.
166
+ */
167
+ groups?: GroupsOptions;
57
168
  }
58
169
  declare const helpPlugin: ({
59
170
  command,
@@ -62,7 +173,8 @@ declare const helpPlugin: ({
62
173
  notes,
63
174
  examples,
64
175
  banner,
65
- formatters
176
+ formatters,
177
+ groups
66
178
  }?: HelpPluginOptions) => Plugin;
67
179
  //#endregion
68
180
  //#region ../plugin-not-found/src/index.d.ts
@@ -91,4 +203,4 @@ declare const versionPlugin: ({
91
203
  flag
92
204
  }?: VersionPluginOptions) => Plugin;
93
205
  //#endregion
94
- export { CompletionsPluginOptions, FriendlyErrorPluginOptions, HelpPluginOptions, completionsPlugin, defaultFormatters, friendlyErrorPlugin, helpPlugin, notFoundPlugin, strictFlagsPlugin, versionPlugin };
206
+ export { CommandHelpOptions, CompletionsPluginOptions, FriendlyErrorPluginOptions, type GroupDefinition, type GroupsOptions, HelpOptions, HelpPluginOptions, completionsPlugin, defaultFormatters, friendlyErrorPlugin, helpPlugin, notFoundPlugin, strictFlagsPlugin, versionPlugin };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clerc",
3
- "version": "1.0.0-beta.2",
3
+ "version": "1.0.0-beta.3",
4
4
  "author": "Ray <i@mk1.io> (https://github.com/so1ve)",
5
5
  "type": "module",
6
6
  "description": "Clerc: The full-featured cli library.",
@@ -44,13 +44,13 @@
44
44
  "access": "public"
45
45
  },
46
46
  "dependencies": {
47
- "@clerc/core": "1.0.0-beta.2",
48
- "@clerc/plugin-help": "1.0.0-beta.2",
49
- "@clerc/plugin-completions": "1.0.0-beta.2",
50
- "@clerc/plugin-not-found": "1.0.0-beta.2",
51
- "@clerc/plugin-friendly-error": "1.0.0-beta.2",
52
- "@clerc/plugin-strict-flags": "1.0.0-beta.2",
53
- "@clerc/plugin-version": "1.0.0-beta.2"
47
+ "@clerc/core": "1.0.0-beta.3",
48
+ "@clerc/plugin-completions": "1.0.0-beta.3",
49
+ "@clerc/plugin-friendly-error": "1.0.0-beta.3",
50
+ "@clerc/plugin-help": "1.0.0-beta.3",
51
+ "@clerc/plugin-not-found": "1.0.0-beta.3",
52
+ "@clerc/plugin-version": "1.0.0-beta.3",
53
+ "@clerc/plugin-strict-flags": "1.0.0-beta.3"
54
54
  },
55
55
  "scripts": {
56
56
  "build": "tsdown",