- Separated input passing from signal calling - Exposed command registry to the broader codebase - Moved command execution call to internal shell logic - TTY is now expected to watch for stdout escape sequences to perform tasks
28 lines
866 B
TypeScript
28 lines
866 B
TypeScript
import type { CommandDescriptor, CommandOutput } from "@core/command";
|
|
import type { CommandIO } from "@core/command_io";
|
|
import { COMMAND_REGISTRY } from "@core/command_registry";
|
|
import { createSuccessResult, type ResultSuccess } from "@core/result";
|
|
import type { ShellState } from "@core/shell_state";
|
|
import type { ShellError } from "@core/util/errors";
|
|
|
|
export const COMMAND_NAME = "help";
|
|
|
|
async function main(io: CommandIO, state: ShellState, args: string[]): Promise<CommandOutput<ShellError>> {
|
|
const e = new TextEncoder();
|
|
for (const entry of COMMAND_REGISTRY.keys()) {
|
|
io.writeStdout(e.encode(` ${entry}\n`));
|
|
}
|
|
|
|
const result: ResultSuccess = createSuccessResult(COMMAND_NAME);
|
|
|
|
return {
|
|
state: state,
|
|
result,
|
|
};
|
|
}
|
|
|
|
export const descriptor: CommandDescriptor = {
|
|
fn: main,
|
|
name: COMMAND_NAME,
|
|
};
|