clerc 1.0.0-beta.3 → 1.0.0-beta.30

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,4 +1,6 @@
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";
3
+ import { ArgumentHandler, Command, OptionHandler } from "@bomb.sh/tab";
2
4
  export * from "@clerc/core";
3
5
 
4
6
  //#region ../plugin-completions/src/index.d.ts
@@ -14,17 +16,42 @@ declare module "@clerc/core" {
14
16
  * @default true
15
17
  */
16
18
  show?: boolean;
19
+ /**
20
+ * Handler to provide custom completions for the command.
21
+ */
22
+ handler?: (command: Command) => void;
23
+ };
24
+ }
25
+ interface FlagCustomOptions {
26
+ /**
27
+ * Completions options for the flag.
28
+ */
29
+ completions?: {
30
+ /**
31
+ * Whether to show the flag in completions output.
32
+ *
33
+ * @default true
34
+ */
35
+ show?: boolean;
36
+ /**
37
+ * Handler to provide custom completions for the flag.
38
+ */
39
+ handler?: OptionHandler;
40
+ };
41
+ }
42
+ interface ParameterCustomOptions {
43
+ /**
44
+ * Completions options for the parameter.
45
+ */
46
+ completions?: {
47
+ /**
48
+ * Handler to provide custom completions for the parameter.
49
+ */
50
+ handler?: ArgumentHandler;
17
51
  };
18
52
  }
19
53
  }
20
- interface CompletionsPluginOptions {
21
- /**
22
- * Whether to register the `completions install` and `completions uninstall` commands.
23
- * @default true
24
- */
25
- managementCommands?: boolean;
26
- }
27
- declare const completionsPlugin: (options?: CompletionsPluginOptions) => Plugin;
54
+ declare const completionsPlugin: () => Plugin;
28
55
  //#endregion
29
56
  //#region ../plugin-friendly-error/src/index.d.ts
30
57
  interface FriendlyErrorPluginOptions {
@@ -35,23 +62,30 @@ declare const friendlyErrorPlugin: ({
35
62
  }?: FriendlyErrorPluginOptions) => Plugin;
36
63
  //#endregion
37
64
  //#region ../parser/src/types.d.ts
65
+ interface FlagDefaultValueFunction<T> {
66
+ (): T;
67
+ display?: string;
68
+ }
69
+ type FlagDefaultValue<T = unknown> = T | FlagDefaultValueFunction<T>;
38
70
  /**
39
71
  * Defines how a string input is converted to the target type T.
40
72
  *
41
73
  * @template T The target type.
42
74
  */
43
- type FlagTypeFunction<T = unknown> = ((value: string) => T) & {
75
+ interface TypeFunction<T = unknown> {
76
+ (value: string): T;
44
77
  /**
45
78
  * Optional display name for the type, useful in help output.
46
79
  * If provided, this will be shown instead of the function name.
47
80
  */
48
- displayName?: string;
49
- };
50
- type FlagType<T = unknown> = FlagTypeFunction<T> | readonly [FlagTypeFunction<T>];
81
+ display?: string;
82
+ }
83
+ type TypeValue<T = unknown> = TypeFunction<T> | readonly [TypeFunction<T>];
51
84
  //#endregion
52
85
  //#region ../plugin-help/src/types.d.ts
53
86
  interface Formatters {
54
- formatFlagType: (type: FlagType) => string;
87
+ formatTypeValue: (type: TypeValue) => string;
88
+ formatFlagDefault: <T>(value: FlagDefaultValue<T>) => string;
55
89
  }
56
90
  /**
57
91
  * A group definition as a tuple of [key, displayName].
@@ -151,9 +185,13 @@ interface HelpPluginOptions {
151
185
  */
152
186
  examples?: [string, string][];
153
187
  /**
154
- * A banner to show before the help output.
188
+ * Header to show before the help output.
155
189
  */
156
- banner?: string;
190
+ header?: string;
191
+ /**
192
+ * Footer to show after the help output.
193
+ */
194
+ footer?: string;
157
195
  /**
158
196
  * Custom formatters for rendering help.
159
197
  */
@@ -172,7 +210,8 @@ declare const helpPlugin: ({
172
210
  showHelpWhenNoCommandSpecified,
173
211
  notes,
174
212
  examples,
175
- banner,
213
+ header,
214
+ footer,
176
215
  formatters,
177
216
  groups
178
217
  }?: HelpPluginOptions) => Plugin;
@@ -202,5 +241,9 @@ declare const versionPlugin: ({
202
241
  command,
203
242
  flag
204
243
  }?: VersionPluginOptions) => Plugin;
244
+ declare namespace index_d_exports {
245
+ export { Cli, CommandHelpOptions, FriendlyErrorPluginOptions, GroupDefinition, GroupsOptions, HelpOptions, HelpPluginOptions, completionsPlugin, defaultFormatters, friendlyErrorPlugin, helpPlugin, notFoundPlugin, strictFlagsPlugin, versionPlugin };
246
+ }
247
+ declare const Cli: (options?: CreateOptions) => Clerc;
205
248
  //#endregion
206
- export { CommandHelpOptions, CompletionsPluginOptions, FriendlyErrorPluginOptions, type GroupDefinition, type GroupsOptions, HelpOptions, HelpPluginOptions, completionsPlugin, defaultFormatters, friendlyErrorPlugin, helpPlugin, notFoundPlugin, strictFlagsPlugin, versionPlugin };
249
+ export { Cli, CommandHelpOptions, 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.3",
3
+ "version": "1.0.0-beta.30",
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.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
- },
55
- "scripts": {
56
- "build": "tsdown",
57
- "watch": "tsdown --watch"
47
+ "@clerc/core": "1.0.0-beta.30",
48
+ "@clerc/plugin-completions": "1.0.0-beta.30",
49
+ "@clerc/plugin-friendly-error": "1.0.0-beta.30",
50
+ "@clerc/plugin-not-found": "1.0.0-beta.30",
51
+ "@clerc/plugin-help": "1.0.0-beta.30",
52
+ "@clerc/plugin-strict-flags": "1.0.0-beta.30",
53
+ "@clerc/plugin-version": "1.0.0-beta.30"
58
54
  }
59
55
  }