26 lines
1.0 KiB
TypeScript
26 lines
1.0 KiB
TypeScript
import { ArgParser, ParsingInto } from './argparser';
|
|
import { Runner } from './runner';
|
|
import { Aliased, Named, Descriptive, Versioned } from './helpdoc';
|
|
declare type Output<Commands extends Record<string, ArgParser<any> & Runner<any, any>>> = {
|
|
[key in keyof Commands]: {
|
|
command: key;
|
|
args: ParsingInto<Commands[key]>;
|
|
};
|
|
}[keyof Commands];
|
|
declare type RunnerOutput<Commands extends Record<string, Runner<any, any> & ArgParser<any>>> = {
|
|
[key in keyof Commands]: {
|
|
command: key;
|
|
value: Commands[key] extends Runner<any, infer X> ? X : never;
|
|
};
|
|
}[keyof Commands];
|
|
/**
|
|
* Combine multiple `command`s into one
|
|
*/
|
|
export declare function subcommands<Commands extends Record<string, ArgParser<any> & Runner<any, any> & Partial<Descriptive & Aliased>>>(config: {
|
|
name: string;
|
|
version?: string;
|
|
cmds: Commands;
|
|
description?: string;
|
|
}): ArgParser<Output<Commands>> & Named & Partial<Descriptive & Versioned> & Runner<Output<Commands>, RunnerOutput<Commands>>;
|
|
export {};
|