29 lines
640 B
TypeScript
29 lines
640 B
TypeScript
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}`;
|
|
}
|
|
|
|
getManPage(): string {
|
|
return "rm - remove files or directories";
|
|
}
|
|
}
|