clerc 1.0.0-beta.9 → 1.0.1

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