@clerc/core
Advanced tools
Comparing version 0.27.1 to 0.28.0
@@ -237,2 +237,25 @@ /** | ||
type StripBrackets<Parameter extends string> = (Parameter extends `<${infer ParameterName}>` | `[${infer ParameterName}]` ? (ParameterName extends `${infer SpreadName}...` ? SpreadName : ParameterName) : never); | ||
type ParameterType<Parameter extends string> = (Parameter extends `<${infer _ParameterName}...>` | `[${infer _ParameterName}...]` ? string[] : Parameter extends `<${infer _ParameterName}>` ? string : Parameter extends `[${infer _ParameterName}]` ? string | undefined : never); | ||
type NonNullableParameters<T extends string[] | undefined> = T extends undefined ? [] : NonNullable<T>; | ||
type TransformParameters<C extends Command> = { | ||
[Parameter in NonNullableParameters<C["parameters"]>[number] as CamelCase<StripBrackets<Parameter>>]: ParameterType<Parameter>; | ||
}; | ||
type MakeEventMap<T extends CommandRecord> = { | ||
[K in keyof T]: [InspectorContext]; | ||
}; | ||
type FallbackFlags<C extends Command> = Equals<NonNullableFlag<C>["flags"], {}> extends true ? Dict<any> : NonNullableFlag<C>["flags"]; | ||
type NonNullableFlag<C extends Command> = TypeFlag<NonNullable<C["flags"]>>; | ||
type ParseFlag<C extends CommandRecord, N extends keyof C> = N extends keyof C ? OmitIndexSignature<NonNullableFlag<C[N]>["flags"]> : FallbackFlags<C[N]>["flags"]; | ||
type ParseRaw<C extends Command> = NonNullableFlag<C> & { | ||
flags: FallbackFlags<C>; | ||
parameters: string[]; | ||
mergedFlags: FallbackFlags<C> & NonNullableFlag<C>["unknownFlags"]; | ||
}; | ||
type ParseParameters<C extends CommandRecord = CommandRecord, N extends keyof C = keyof C> = Equals<TransformParameters<C[N]>, {}> extends true ? N extends keyof C ? TransformParameters<C[N]> : Dict<string | string[] | undefined> : TransformParameters<C[N]>; | ||
interface Plugin<T extends Clerc = Clerc, U extends Clerc = Clerc> { | ||
setup: (cli: T) => U; | ||
} | ||
type CommandType = RootType | string; | ||
@@ -272,21 +295,3 @@ type FlagOptions = FlagSchema & { | ||
} | ||
type StripBrackets<Parameter extends string> = (Parameter extends `<${infer ParameterName}>` | `[${infer ParameterName}]` ? (ParameterName extends `${infer SpreadName}...` ? SpreadName : ParameterName) : never); | ||
type ParameterType<Parameter extends string> = (Parameter extends `<${infer _ParameterName}...>` | `[${infer _ParameterName}...]` ? string[] : Parameter extends `<${infer _ParameterName}>` ? string : Parameter extends `[${infer _ParameterName}]` ? string | undefined : never); | ||
type MakeEventMap<T extends CommandRecord> = { | ||
[K in keyof T]: [InspectorContext]; | ||
}; | ||
type PossibleInputKind = string | number | boolean | Dict<any>; | ||
type NonNullableParameters<T extends string[] | undefined> = T extends undefined ? [] : NonNullable<T>; | ||
type TransformParameters<C extends Command> = { | ||
[Parameter in NonNullableParameters<C["parameters"]>[number] as CamelCase<StripBrackets<Parameter>>]: ParameterType<Parameter>; | ||
}; | ||
type FallbackFlags<C extends Command> = Equals<NonNullableFlag<C>["flags"], {}> extends true ? Dict<any> : NonNullableFlag<C>["flags"]; | ||
type NonNullableFlag<C extends Command> = TypeFlag<NonNullable<C["flags"]>>; | ||
type ParseFlag<C extends CommandRecord, N extends keyof C> = N extends keyof C ? OmitIndexSignature<NonNullableFlag<C[N]>["flags"]> : FallbackFlags<C[N]>["flags"]; | ||
type ParseRaw<C extends Command> = NonNullableFlag<C> & { | ||
flags: FallbackFlags<C>; | ||
parameters: string[]; | ||
mergedFlags: FallbackFlags<C> & NonNullableFlag<C>["unknownFlags"]; | ||
}; | ||
type ParseParameters<C extends CommandRecord = CommandRecord, N extends keyof C = keyof C> = Equals<TransformParameters<C[N]>, {}> extends true ? N extends keyof C ? TransformParameters<C[N]> : Dict<string | string[] | undefined> : TransformParameters<C[N]>; | ||
interface HandlerContext<C extends CommandRecord = CommandRecord, N extends keyof C = keyof C> { | ||
@@ -324,4 +329,4 @@ name?: LiteralUnion<N, string>; | ||
} | ||
interface Plugin<T extends Clerc = Clerc, U extends Clerc = Clerc> { | ||
setup: (cli: T) => U; | ||
interface I18N { | ||
add: () => void; | ||
} | ||
@@ -515,2 +520,2 @@ | ||
export { Clerc, Command, CommandAlias, CommandCustomProperties, CommandExistsError, CommandNameConflictError, CommandOptions, CommandRecord, CommandType, CommandWithHandler, DescriptionNotSetError, FallbackType, Flag, FlagOptions, Flags, Handler, HandlerContext, HandlerInCommand, Inspector, InspectorContext, InspectorFn, InspectorObject, InvalidCommandNameError, MakeEventMap, NameNotSetError, NoCommandGivenError, NoSuchCommandError, ParseOptions, Plugin, PossibleInputKind, Root, RootType, VersionNotSetError, compose, defineCommand, defineHandler, defineInspector, definePlugin, formatCommandName, isInvalidName, resolveArgv, resolveCommand, resolveFlattenCommands, resolveParametersBeforeFlag, resolveRootCommands, resolveSubcommandsByParent, withBrackets }; | ||
export { Clerc, Command, CommandAlias, CommandCustomProperties, CommandExistsError, CommandNameConflictError, CommandOptions, CommandRecord, CommandType, CommandWithHandler, DescriptionNotSetError, FallbackType, Flag, FlagOptions, Flags, Handler, HandlerContext, HandlerInCommand, I18N, Inspector, InspectorContext, InspectorFn, InspectorObject, InvalidCommandNameError, MakeEventMap, NameNotSetError, NoCommandGivenError, NoSuchCommandError, ParseOptions, Plugin, PossibleInputKind, Root, RootType, VersionNotSetError, compose, defineCommand, defineHandler, defineInspector, definePlugin, formatCommandName, isInvalidName, resolveArgv, resolveCommand, resolveFlattenCommands, resolveParametersBeforeFlag, resolveRootCommands, resolveSubcommandsByParent, withBrackets }; |
{ | ||
"name": "@clerc/core", | ||
"version": "0.27.1", | ||
"version": "0.28.0", | ||
"author": "Ray <nn_201312@163.com> (https://github.com/so1ve)", | ||
@@ -54,3 +54,3 @@ "description": "Clerc core", | ||
"type-flag": "^3.0.0", | ||
"@clerc/utils": "0.27.1" | ||
"@clerc/utils": "0.28.0" | ||
}, | ||
@@ -57,0 +57,0 @@ "scripts": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
32119
506