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