Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions src/ts/terminal/commands/touch.ts
Original file line number Diff line number Diff line change
@@ -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<number> {
const names = argv;

for (const name of names) await term.writeFile(name, new Blob());
return 0;
}
}
4 changes: 3 additions & 1 deletion src/ts/terminal/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -73,7 +74,8 @@ export const TerminalCommandStore: (typeof TerminalProcess)[] = [
DevenvCommand,
PkgCommand,
KlogCommand,
InputCommand
InputCommand,
TouchCommand,
];

export const ESC = `\x1b[`;
Expand Down