Skip to content

Commit 094b85d

Browse files
committed
feat(core, plugin-help)!: rename types and functions
1 parent 67d2ca0 commit 094b85d

8 files changed

Lines changed: 18 additions & 18 deletions

File tree

docs/official-plugins/plugin-help.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ const cli = Clerc.create()
186186
banner: "Welcome to My CLI application!", // Custom banner
187187
formatters: {
188188
// Custom type formatting functions
189-
formatFlagType: (type: FlagType) => {
189+
formatTypeValue: (type) => {
190190
if (typeof type === "function") {
191191
return type.name;
192192
}

docs/zh/official-plugins/plugin-help.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ const cli = Clerc.create()
183183
banner: "欢迎使用 My CLI 应用程序!", // 自定义横幅
184184
formatters: {
185185
// 自定义类型格式化函数
186-
formatFlagType: (type: FlagType) => {
186+
formatTypeValue: (type) => {
187187
if (typeof type === "function") {
188188
return type.name;
189189
}

packages/core/src/types/flag.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import type { FlagOptions, FlagType } from "@clerc/parser";
1+
import type { FlagOptions, TypeValue } from "@clerc/parser";
22

33
export declare interface FlagCustomOptions {}
44

55
export type ClercFlagOptions = FlagOptions & {
66
description?: string;
77
} & FlagCustomOptions;
88

9-
export type ClercFlagDefinitionValue = ClercFlagOptions | FlagType;
9+
export type ClercFlagDefinitionValue = ClercFlagOptions | TypeValue;
1010

1111
export type ClercFlagsDefinition = Record<string, ClercFlagDefinitionValue>;

packages/parser/src/types.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,11 @@ export type IgnoreFunction = (
3636
arg: string,
3737
) => boolean;
3838

39-
export type FlagType<T = unknown> =
39+
export type TypeValue<T = unknown> =
4040
| TypeFunction<T>
4141
| readonly [TypeFunction<T>];
4242

43-
export interface BaseFlagOptions<T extends FlagType = FlagType> {
43+
export interface BaseFlagOptions<T extends TypeValue = TypeValue> {
4444
/**
4545
* The type constructor or a function to convert the string value.
4646
* To support multiple occurrences of a flag (e.g., --file a --file b), wrap the type in an array: [String], [Number].
@@ -68,7 +68,7 @@ export type FlagOptions =
6868
| (BaseFlagOptions & {
6969
negatable?: never;
7070
});
71-
export type FlagDefinitionValue = FlagOptions | FlagType;
71+
export type FlagDefinitionValue = FlagOptions | TypeValue;
7272
export type FlagsDefinition = Record<string, FlagDefinitionValue>;
7373

7474
/**
@@ -148,10 +148,10 @@ type _InferFlags<T extends FlagsDefinition> = {
148148
: T[K] extends ObjectConstructor | { type: ObjectConstructor }
149149
? ObjectInputType | InferFlagDefault<T[K], never>
150150
: T[K] extends
151-
| readonly [FlagType<infer U>]
152-
| { type: readonly [FlagType<infer U>] }
151+
| readonly [TypeValue<infer U>]
152+
| { type: readonly [TypeValue<infer U>] }
153153
? U[] | InferFlagDefault<T[K], never>
154-
: T[K] extends FlagType<infer U> | { type: FlagType<infer U> }
154+
: T[K] extends TypeValue<infer U> | { type: TypeValue<infer U> }
155155
?
156156
| U
157157
| InferFlagDefault<
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { Formatters } from "./types";
2-
import { formatFlagDefault, formatFlagType } from "./utils";
2+
import { formatFlagDefault, formatTypeValue } from "./utils";
33

44
export const defaultFormatters: Formatters = {
5-
formatFlagType,
5+
formatTypeValue,
66
formatFlagDefault,
77
};

packages/plugin-help/src/renderer.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ export class HelpRenderer {
208208

209209
return [
210210
yc.bold(key),
211-
type ? this._formatters.formatFlagType(type) : "string",
211+
type ? this._formatters.formatTypeValue(type) : "string",
212212
description,
213213
].filter(isTruthy);
214214
});
@@ -374,7 +374,7 @@ export class HelpRenderer {
374374
)
375375
.map(formatFlagName)
376376
.join(", ");
377-
const type = this._formatters.formatFlagType(flag.type);
377+
const type = this._formatters.formatTypeValue(flag.type);
378378

379379
return [
380380
yc.bold([flagName, aliases].filter(Boolean).join(", ")),

packages/plugin-help/src/types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import type { FlagDefaultValue, FlagType } from "@clerc/parser";
1+
import type { FlagDefaultValue, TypeValue } from "@clerc/parser";
22

33
export interface Formatters {
4-
formatFlagType: (type: FlagType) => string;
4+
formatTypeValue: (type: TypeValue) => string;
55
formatFlagDefault: <T>(value: FlagDefaultValue<T>) => string;
66
}
77

packages/plugin-help/src/utils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import type { FlagDefaultValue, FlagType } from "@clerc/parser";
1+
import type { FlagDefaultValue, TypeValue } from "@clerc/parser";
22

3-
export function formatFlagType(type: FlagType): string {
3+
export function formatTypeValue(type: TypeValue): string {
44
if (typeof type === "function") {
55
return type.display ?? type.name;
66
}

0 commit comments

Comments
 (0)