WRITE UNIT TESTS!!!

first async command working, no unit tests done AGAING
This commit is contained in:
2026-08-23 06:39:37 +02:00
parent e313aa5b9d
commit 268729bb62
18 changed files with 331 additions and 93 deletions
+44
View File
@@ -0,0 +1,44 @@
import type { CommandDescriptor, CommandOutput } from "@core/command";
import type { CommandIO } from "@core/command_io";
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";
const COMMAND_NAME = "async";
async function main(
io: CommandIO,
state: ShellState,
__flags: string[],
__args: string[],
): Promise<CommandOutput<ShellError>> {
while (true) {
const out = await io.getSignal();
if (out.type === "INPUT") {
const encoded = new TextEncoder().encode(("user pressed: " + out.payload + "\n") as string);
io.writeStdout(encoded);
if (out.payload === "ctrl+c") {
const result: ResultSuccess = {
type: "success",
exitCode: 0,
stdout: createImmutableBuffer(new Uint8Array()),
stderr: createImmutableBuffer(new Uint8Array()),
commandName: COMMAND_NAME,
};
return {
state: state,
result,
};
}
}
}
}
export const descriptor = {
fn: main,
name: COMMAND_NAME,
} satisfies CommandDescriptor;