diff --git a/src/ts/terminal/commands/touch.ts b/src/ts/terminal/commands/touch.ts new file mode 100644 index 00000000..f0268682 --- /dev/null +++ b/src/ts/terminal/commands/touch.ts @@ -0,0 +1,25 @@ +import type { Arguments } from "$types/terminal"; +import type { ArcTerminal } from ".."; +import { TerminalProcess } from "../process"; + +export class TouchCommand extends TerminalProcess { + public static keyword: string = "touch"; + public static description: string = "Creates an empty file with the specified name."; + + //#region LIFECYCLE + + constructor(pid: number, parentPid: number) { + super(pid, parentPid); + + this.setSource(__SOURCE__); + } + + //#endregion + + protected async main(term: ArcTerminal, _: Arguments, argv: string[]): Promise { + const names = argv; + + for (const name of names) await term.writeFile(name, new Blob()); + return 0; + } +} diff --git a/src/ts/terminal/store.ts b/src/ts/terminal/store.ts index 83a8a963..56670064 100755 --- a/src/ts/terminal/store.ts +++ b/src/ts/terminal/store.ts @@ -33,6 +33,7 @@ import { SpawnCommand } from "./commands/spawn"; import { SudoCommand } from "./commands/sudo"; import { TasksCommand } from "./commands/tasks"; import { TestCommand } from "./commands/test"; +import { TouchCommand } from "./commands/touch"; import { TreeCommand } from "./commands/tree"; import { VerCommand } from "./commands/ver"; import type { TerminalProcess } from "./process"; @@ -73,7 +74,8 @@ export const TerminalCommandStore: (typeof TerminalProcess)[] = [ DevenvCommand, PkgCommand, KlogCommand, - InputCommand + InputCommand, + TouchCommand, ]; export const ESC = `\x1b[`;