From 6e3cfead573ca8d97e5ba318bce1d44b20ba390b Mon Sep 17 00:00:00 2001 From: oAnblu <194724113+oAnblu@users.noreply.github.com> Date: Wed, 8 Oct 2025 15:55:14 +0300 Subject: [PATCH] Add `touch` command --- src/ts/terminal/commands/touch.ts | 25 +++++++++++++++++++++++++ src/ts/terminal/store.ts | 2 ++ 2 files changed, 27 insertions(+) create mode 100644 src/ts/terminal/commands/touch.ts diff --git a/src/ts/terminal/commands/touch.ts b/src/ts/terminal/commands/touch.ts new file mode 100644 index 000000000..f0268682b --- /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 d6411eb3d..c82446306 100755 --- a/src/ts/terminal/store.ts +++ b/src/ts/terminal/store.ts @@ -30,6 +30,7 @@ import { ShutdownCommand } from "./commands/shutdown"; import { SpawnCommand } from "./commands/spawn"; 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"; @@ -68,6 +69,7 @@ export const TerminalCommandStore: (typeof TerminalProcess)[] = [ DrivesCommand, DevenvCommand, PkgCommand, + TouchCommand, ]; export const ESC = `\x1b[`;