import type { ParseContext } from "./argparser"; import type { HelpTopic } from "./helpdoc"; /** * An example to show in help output */ export type Example = { /** Description of what this example does */ description: string; /** The command to run */ command: string; }; /** * Structured data for command help */ export type CommandHelpData = { /** The command name */ name: string; /** Breadcrumb path to this command (e.g., ["sandbox", "create"]) */ path: string[]; /** Version string */ version?: string; /** Description of the command */ description?: string; /** Aliases for the command */ aliases?: string[]; /** Help topics for flags, options, arguments */ helpTopics: HelpTopic[]; /** Examples to show in help output */ examples?: Example[]; }; /** * Structured data for subcommands help */ export type SubcommandsHelpData = { /** The name of the subcommands group */ name: string; /** Breadcrumb path (e.g., ["sandbox"]) */ path: string[]; /** Version string */ version?: string; /** Description of the subcommands group */ description?: string; /** Available subcommands */ commands: Array<{ name: string; description?: string; aliases?: string[]; /** Help topics from the command (to derive argument hints) */ helpTopics: HelpTopic[]; }>; /** Examples to show in help output */ examples?: Example[]; }; /** * Interface for custom help formatters. * Implement this to create your own help output style. */ export interface HelpFormatter { /** Format help output for a single command */ formatCommand(data: CommandHelpData, context: ParseContext): string; /** Format help output for a subcommands group */ formatSubcommands(data: SubcommandsHelpData, context: ParseContext): string; } /** * Set a custom help formatter to be used for all commands. * * @example * ```ts * import { setDefaultHelpFormatter } from "cmd-ts"; * * setDefaultHelpFormatter({ * formatCommand(data, context) { * return `My CLI ${data.version}\n${data.description}`; * }, * formatSubcommands(data, context) { * return `Commands: ${data.commands.map(c => c.name).join(", ")}`; * }, * }); * ``` */ export declare function setDefaultHelpFormatter(formatter: HelpFormatter): void; /** * Reset the help formatter to the default. * Useful for testing. */ export declare function resetHelpFormatter(): void; /** * Get the current help formatter (custom or default). * @internal */ export declare function getHelpFormatter(): HelpFormatter; /** * The default help formatter that matches cmd-ts's original output style. */ export declare const defaultHelpFormatter: HelpFormatter;