import { PickCommandByName, PossibleCommands } from "./type-utils.mjs"; import { PadroneContextInterceptor, PadroneInterceptorFn } from "../types/interceptor.mjs"; import { AnyPadroneCommand, PadroneCommand } from "../types/command.mjs"; import { AnyPadroneProgram } from "../types/builder.mjs"; //#region src/util/type-helpers.d.ts /** * Extracts the input type of the arguments schema from a command. * @example * ```ts * type Args = InferArgsInput; * ``` */ type InferArgsInput = T['~types']['argsInput']; /** * Extracts the output type of the arguments schema from a command. * @example * ```ts * type Args = InferArgsOutput; * ``` */ type InferArgsOutput = T['~types']['argsOutput']; /** * Extracts the user-defined context type from a command (excludes interceptor-provided context). * @example * ```ts * type Ctx = InferContext; * ``` */ type InferContext = T['~types']['context']; /** * Extracts the interceptor-provided context type from a command. * @example * ```ts * type Provided = InferContextProvided; * ``` */ type InferContextProvided = T['~types']['contextProvided']; /** * Extracts the context type that a context-providing interceptor injects. * @example * ```ts * type AuthCtx = InferInterceptorContext; * ``` */ type InferInterceptorContext> = T['~context']; /** * Extracts the required context type from an interceptor with `.requires()`. * @example * ```ts * type Requires = InferInterceptorRequires; * ``` */ type InferInterceptorRequires = T['~contextRequires'] extends ((ctx: infer R) => void) ? R : unknown; /** * Gets a command type by its path from a program or command tree. * Supports both full paths (e.g., "config set") and alias paths. * @example * ```ts * const program = createPadrone('cli') * .command('config', c => c * .command('set', c => c.arguments(...).action(...)) * .command('get', c => c.arguments(...).action(...)) * ); * * type SetCommand = InferCommand; * type GetCommand = InferCommand; * ``` */ type InferCommand> = T extends AnyPadroneProgram ? PickCommandByName<[PadroneCommand<'', '', any, any, T['~types']['commands']>], TPath> : T extends AnyPadroneCommand ? PickCommandByName<[T], TPath> : never; //#endregion export { InferArgsInput, InferArgsOutput, InferCommand, InferContext, InferContextProvided, InferInterceptorContext, InferInterceptorRequires }; //# sourceMappingURL=type-helpers.d.mts.map