clerc 1.0.0-beta.2 → 1.0.0-beta.21

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.
@@ -0,0 +1,42 @@
1
+ //#region rolldown:runtime
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (all, symbols) => {
7
+ let target = {};
8
+ for (var name in all) {
9
+ __defProp(target, name, {
10
+ get: all[name],
11
+ enumerable: true
12
+ });
13
+ }
14
+ if (symbols) {
15
+ __defProp(target, Symbol.toStringTag, { value: "Module" });
16
+ }
17
+ return target;
18
+ };
19
+ var __copyProps = (to, from, except, desc) => {
20
+ if (from && typeof from === "object" || typeof from === "function") {
21
+ for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
22
+ key = keys[i];
23
+ if (!__hasOwnProp.call(to, key) && key !== except) {
24
+ __defProp(to, key, {
25
+ get: ((k) => from[k]).bind(null, key),
26
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
27
+ });
28
+ }
29
+ }
30
+ }
31
+ return to;
32
+ };
33
+ var __reExport = (target, mod, secondTarget, symbols) => {
34
+ if (symbols) {
35
+ __defProp(target, Symbol.toStringTag, { value: "Module" });
36
+ secondTarget && __defProp(secondTarget, Symbol.toStringTag, { value: "Module" });
37
+ }
38
+ __copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default");
39
+ };
40
+
41
+ //#endregion
42
+ export { __reExport as n, __export as t };
package/dist/index.d.ts CHANGED
@@ -1,7 +1,23 @@
1
- import { Plugin } from "@clerc/core";
1
+ import { n as __reExport, t as __export } from "./chunk-CYeTv9WL.js";
2
+ import { Clerc, CreateOptions, Plugin } from "@clerc/core";
2
3
  export * from "@clerc/core";
3
4
 
4
5
  //#region ../plugin-completions/src/index.d.ts
6
+ declare module "@clerc/core" {
7
+ interface CommandCustomOptions {
8
+ /**
9
+ * Completions options for the command.
10
+ */
11
+ completions?: {
12
+ /**
13
+ * Whether to show the command in completions output.
14
+ *
15
+ * @default true
16
+ */
17
+ show?: boolean;
18
+ };
19
+ }
20
+ }
5
21
  interface CompletionsPluginOptions {
6
22
  /**
7
23
  * Whether to register the `completions install` and `completions uninstall` commands.
@@ -20,40 +36,143 @@ declare const friendlyErrorPlugin: ({
20
36
  }?: FriendlyErrorPluginOptions) => Plugin;
21
37
  //#endregion
22
38
  //#region ../parser/src/types.d.ts
39
+ interface FlagDefaultValueFunction<T> {
40
+ (): T;
41
+ display?: string;
42
+ }
43
+ type FlagDefaultValue<T = unknown> = T | FlagDefaultValueFunction<T>;
23
44
  /**
24
45
  * Defines how a string input is converted to the target type T.
25
46
  *
26
47
  * @template T The target type.
27
48
  */
28
- type FlagTypeFunction<T = unknown> = (value: string) => T;
29
- type FlagType<T = unknown> = FlagTypeFunction<T> | readonly [FlagTypeFunction<T>];
49
+ interface TypeFunction<T = unknown> {
50
+ (value: string): T;
51
+ /**
52
+ * Optional display name for the type, useful in help output.
53
+ * If provided, this will be shown instead of the function name.
54
+ */
55
+ display?: string;
56
+ }
57
+ type FlagType<T = unknown> = TypeFunction<T> | readonly [TypeFunction<T>];
30
58
  //#endregion
31
59
  //#region ../plugin-help/src/types.d.ts
32
60
  interface Formatters {
33
61
  formatFlagType: (type: FlagType) => string;
62
+ formatFlagDefault: <T>(value: FlagDefaultValue<T>) => string;
63
+ }
64
+ /**
65
+ * A group definition as a tuple of [key, displayName].
66
+ * The key is used in help options to assign items to groups.
67
+ * The displayName is shown in the help output.
68
+ */
69
+ type GroupDefinition = [key: string, name: string];
70
+ /**
71
+ * Options for defining groups in help output.
72
+ */
73
+ interface GroupsOptions {
74
+ /**
75
+ * Groups for commands.
76
+ * Each group is defined as `[key, name]`.
77
+ */
78
+ commands?: GroupDefinition[];
79
+ /**
80
+ * Groups for command-specific flags.
81
+ * Each group is defined as `[key, name]`.
82
+ */
83
+ flags?: GroupDefinition[];
84
+ /**
85
+ * Groups for global flags.
86
+ * Each group is defined as `[key, name]`.
87
+ */
88
+ globalFlags?: GroupDefinition[];
34
89
  }
35
90
  //#endregion
36
91
  //#region ../plugin-help/src/formatters.d.ts
37
92
  declare const defaultFormatters: Formatters;
38
93
  //#endregion
39
94
  //#region ../plugin-help/src/index.d.ts
95
+ interface HelpOptions {
96
+ /**
97
+ * The group this item belongs to.
98
+ * The group must be defined in the `groups` option of `helpPlugin()`.
99
+ */
100
+ group?: string;
101
+ }
102
+ interface CommandHelpOptions extends HelpOptions {
103
+ /**
104
+ * Whether to show the command in help output.
105
+ *
106
+ * @default true
107
+ */
108
+ show?: boolean;
109
+ /**
110
+ * Notes to show in the help output.
111
+ */
112
+ notes?: string[];
113
+ /**
114
+ * Examples to show in the help output.
115
+ * Each example is a tuple of `[command, description]`.
116
+ */
117
+ examples?: [string, string][];
118
+ }
40
119
  declare module "@clerc/core" {
41
120
  interface CommandCustomOptions {
42
- help?: {
43
- showInHelp?: boolean;
44
- notes?: string[];
45
- examples?: [string, string][];
46
- };
121
+ /**
122
+ * Help options for the command.
123
+ */
124
+ help?: CommandHelpOptions;
125
+ }
126
+ interface FlagCustomOptions {
127
+ /**
128
+ * Help options for the flag.
129
+ */
130
+ help?: HelpOptions;
47
131
  }
48
132
  }
49
133
  interface HelpPluginOptions {
134
+ /**
135
+ * Whether to register the `help` command.
136
+ *
137
+ * @default true
138
+ */
50
139
  command?: boolean;
140
+ /**
141
+ * Whether to register the `--help` global flag.
142
+ *
143
+ * @default true
144
+ */
51
145
  flag?: boolean;
146
+ /**
147
+ * Whether to show help when no command is specified.
148
+ *
149
+ * @default true
150
+ */
52
151
  showHelpWhenNoCommandSpecified?: boolean;
152
+ /**
153
+ * Notes to show in the help output.
154
+ */
53
155
  notes?: string[];
156
+ /**
157
+ * Examples to show in the help output.
158
+ * Each example is a tuple of `[command, description]`.
159
+ */
54
160
  examples?: [string, string][];
161
+ /**
162
+ * A banner to show before the help output.
163
+ */
55
164
  banner?: string;
165
+ /**
166
+ * Custom formatters for rendering help.
167
+ */
56
168
  formatters?: Partial<Formatters>;
169
+ /**
170
+ * Group definitions for commands and flags.
171
+ * Groups allow organizing commands and flags into logical sections in help output.
172
+ * Each group is defined as `[key, name]` where `key` is the identifier used in help options
173
+ * and `name` is the display name shown in help output.
174
+ */
175
+ groups?: GroupsOptions;
57
176
  }
58
177
  declare const helpPlugin: ({
59
178
  command,
@@ -62,7 +181,8 @@ declare const helpPlugin: ({
62
181
  notes,
63
182
  examples,
64
183
  banner,
65
- formatters
184
+ formatters,
185
+ groups
66
186
  }?: HelpPluginOptions) => Plugin;
67
187
  //#endregion
68
188
  //#region ../plugin-not-found/src/index.d.ts
@@ -90,5 +210,9 @@ declare const versionPlugin: ({
90
210
  command,
91
211
  flag
92
212
  }?: VersionPluginOptions) => Plugin;
213
+ declare namespace index_d_exports {
214
+ export { Cli, CommandHelpOptions, CompletionsPluginOptions, FriendlyErrorPluginOptions, GroupDefinition, GroupsOptions, HelpOptions, HelpPluginOptions, completionsPlugin, defaultFormatters, friendlyErrorPlugin, helpPlugin, notFoundPlugin, strictFlagsPlugin, versionPlugin };
215
+ }
216
+ declare const Cli: (options?: CreateOptions) => Clerc;
93
217
  //#endregion
94
- export { CompletionsPluginOptions, FriendlyErrorPluginOptions, HelpPluginOptions, completionsPlugin, defaultFormatters, friendlyErrorPlugin, helpPlugin, notFoundPlugin, strictFlagsPlugin, versionPlugin };
218
+ export { Cli, CommandHelpOptions, CompletionsPluginOptions, FriendlyErrorPluginOptions, type GroupDefinition, type GroupsOptions, HelpOptions, HelpPluginOptions, completionsPlugin, defaultFormatters, friendlyErrorPlugin, helpPlugin, notFoundPlugin, strictFlagsPlugin, versionPlugin };
package/dist/index.js CHANGED
@@ -1,15 +1,25 @@
1
+ import { n as __reExport, t as __export } from "./chunk-CYeTv9WL.js";
2
+ import { Clerc } from "@clerc/core";
3
+ import { helpPlugin } from "@clerc/plugin-help";
4
+ import { versionPlugin } from "@clerc/plugin-version";
5
+
1
6
  export * from "@clerc/core"
2
7
 
8
+ export * from "@clerc/plugin-help"
9
+
10
+ export * from "@clerc/plugin-version"
11
+
3
12
  export * from "@clerc/plugin-completions"
4
13
 
5
14
  export * from "@clerc/plugin-friendly-error"
6
15
 
7
- export * from "@clerc/plugin-help"
8
-
9
16
  export * from "@clerc/plugin-not-found"
10
17
 
11
18
  export * from "@clerc/plugin-strict-flags"
12
19
 
13
- export * from "@clerc/plugin-version"
20
+ //#region src/index.ts
21
+ var src_exports = /* @__PURE__ */ __export({ Cli: () => Cli });
22
+ const Cli = (options) => Clerc.create(options).use(versionPlugin()).use(helpPlugin());
14
23
 
15
- export { };
24
+ //#endregion
25
+ export { Cli };
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.21",
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,16 +44,12 @@
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"
54
- },
55
- "scripts": {
56
- "build": "tsdown",
57
- "watch": "tsdown --watch"
47
+ "@clerc/core": "1.0.0-beta.21",
48
+ "@clerc/plugin-friendly-error": "1.0.0-beta.21",
49
+ "@clerc/plugin-not-found": "1.0.0-beta.21",
50
+ "@clerc/plugin-version": "1.0.0-beta.21",
51
+ "@clerc/plugin-strict-flags": "1.0.0-beta.21",
52
+ "@clerc/plugin-completions": "1.0.0-beta.21",
53
+ "@clerc/plugin-help": "1.0.0-beta.21"
58
54
  }
59
55
  }