18 lines
642 B
TypeScript
18 lines
642 B
TypeScript
|
|
import type { Command, CommandSchema } from './types.js';
|
||
|
|
|
||
|
|
export type CommandRunnerContext<TContext> = {
|
||
|
|
context: TContext;
|
||
|
|
run: (input: string) => Promise<{ success: true; result: unknown } | { success: false; error: string }>;
|
||
|
|
runParsed: (command: Command) => Promise<{ success: true; result: unknown } | { success: false; error: string }>;
|
||
|
|
};
|
||
|
|
|
||
|
|
export type CommandRunnerHandler<TContext, TResult> = (
|
||
|
|
this: CommandRunnerContext<TContext>,
|
||
|
|
command: Command
|
||
|
|
) => Promise<TResult>;
|
||
|
|
|
||
|
|
export type CommandRunner<TContext, TResult = unknown> = {
|
||
|
|
schema: CommandSchema;
|
||
|
|
run: CommandRunnerHandler<TContext, TResult>;
|
||
|
|
};
|