resolvePath function implemented and tested, all green.
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
import type { CommandDescriptor, CommandOutput } from "@core/command";
|
||||
import type { ResultSuccess, ShellError } from "@core/result";
|
||||
import type { ShellState } from "@core/shell_state";
|
||||
import { createImmutableBuffer } from "@core/util/immutable_buffer";
|
||||
|
||||
export const COMMAND_NAME = "echo";
|
||||
|
||||
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,
|
||||
};
|
||||
Reference in New Issue
Block a user