/** * Structural contract for a subcommand arg parser. * * `parse` receives the raw argv slice (tokens after the subcommand name) * and returns either a parsed result of type T or an error descriptor. * The caller is responsible for detecting the error branch via the * `"error" in result` guard. * * @template T — the parsed result type (subcommand-specific) */ export interface SubcommandArgsParser { parse(args: string[]): T | { error: string; }; } /** * Convenience union alias for the return type of `SubcommandArgsParser.parse`. * * Usage: `function parseArgs(args: string[]): ParseResultOrError` */ export type ParseResultOrError = T | { error: string; };