Files
termos/src/core/commands/echo.ts
T
ChaosMaker 7348d3723e small tweaks to the file structure, and reorganization of the codebase.
preparations for session manager function implementations
2026-07-28 17:54:02 +02:00

34 lines
956 B
TypeScript

import type { CommandDescriptor, CommandOutput } from "@core/command";
import type { ResultSuccess } from "@core/result";
import type { ShellState } from "@core/shell_state";
import type { ShellError } from "@core/util/errors";
import { createImmutableBuffer } from "@core/util/immutable_buffer";
export const COMMAND_NAME = "echo";
//Need to implement escape sequences
function main(state: ShellState, flags: string[], args: string[]): CommandOutput<ShellError> {
const joined = args.join(" ");
const encoded = new TextEncoder().encode(joined);
const stdout = createImmutableBuffer(encoded);
const result: ResultSuccess = {
type: "success",
exitCode: 0,
stdout,
stderr: createImmutableBuffer(new Uint8Array()),
commandName: COMMAND_NAME,
};
return {
state: state,
result,
};
}
export const descriptor: CommandDescriptor = {
fn: main,
name: COMMAND_NAME,
};