Files
termos/src/core/command.ts
T
2026-09-03 11:15:05 +02:00

26 lines
707 B
TypeScript

import type { CommandIO } from "./command_io";
import type { Result } from "./result";
import type { ShellState } from "./shell_state";
import type { ShellError } from "./util/errors";
export type CommandFn = (io: CommandIO, state: ShellState, args: string[]) => Promise<CommandOutput<ShellError>>;
export interface CommandDescriptor {
fn: CommandFn;
name: string;
flags?: readonly FlagDescriptor[];
requiresRoot?: boolean;
description?: string;
keybinds?: readonly string[];
}
export interface FlagDescriptor {
name: string;
takesValue?: boolean;
}
export interface CommandOutput<E extends ShellError> {
readonly state: ShellState;
readonly result: Result<E>;
}