21 lines
1.0 KiB
TypeScript
21 lines
1.0 KiB
TypeScript
import { PrintHelp, Versioned } from './helpdoc';
|
|
import { ParseContext, ParsingResult, Register } from './argparser';
|
|
import { Result } from './Result';
|
|
import { Exit } from './effects';
|
|
export declare type Handling<Values, Result> = {
|
|
handler: (values: Values) => Result;
|
|
};
|
|
export declare type Runner<HandlerArgs, HandlerResult> = PrintHelp & Partial<Versioned> & Register & Handling<HandlerArgs, HandlerResult> & {
|
|
run(context: ParseContext): Promise<ParsingResult<HandlerResult>>;
|
|
};
|
|
export declare type Into<R extends Runner<any, any>> = R extends Runner<any, infer X> ? X : never;
|
|
export declare function run<R extends Runner<any, any>>(ap: R, strings: string[]): Promise<Into<R>>;
|
|
/**
|
|
* Runs a command but does not apply any effect
|
|
*/
|
|
export declare function runSafely<R extends Runner<any, any>>(ap: R, strings: string[]): Promise<Result<Exit, Into<R>>>;
|
|
/**
|
|
* Run a command but don't quit. Returns an `Result` instead.
|
|
*/
|
|
export declare function dryRun<R extends Runner<any, any>>(ap: R, strings: string[]): Promise<Result<string, Into<R>>>;
|