implement shell command interface and add basic commands (echo, ls, pwd, cd, touch, cat, rm) with syscall integration
This commit is contained in:
15
src/shell/commands/cat.ts
Normal file
15
src/shell/commands/cat.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import { IShellCommand } from "./IShellCommand";
|
||||
import { ShellSyscall } from "../ShellSyscall";
|
||||
|
||||
export class cat implements IShellCommand {
|
||||
constructor(private syscall: ShellSyscall) {}
|
||||
|
||||
getName(): string {
|
||||
return "cat";
|
||||
}
|
||||
|
||||
execute(args: string[]): string {
|
||||
if (args.length === 0) return "cat: missing file operand";
|
||||
return this.syscall.readFile(args[0]);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user