24 lines
608 B
TypeScript
24 lines
608 B
TypeScript
import type { Result, ShellError } from "./result";
|
|
import type { ShellState } from "./shell_state";
|
|
|
|
type CommandFn = (state: ShellState, flags: string[], args: string[]) => CommandOutput<ShellError>;
|
|
|
|
export interface CommandDescriptor {
|
|
fn: CommandFn;
|
|
name: string;
|
|
flags?: readonly FlagDescriptor[];
|
|
requresRoot?: 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>;
|
|
}
|