Files
wunix.rhpidfyre.io/src/rt/shell/command/builtin/cd.ts
rhpidfyre 3640f022f6 working on the file system
cd can now display folders in blue
2025-02-23 23:13:05 -05:00

15 lines
531 B
TypeScript

import { set_working_dir, SetDirStatus } from "../../fs/fn"
import type { Args, Term } from "../list"
import stdout from "../../../elements/stdout"
export default function cd(term: Term, args: Args): boolean {
const new_dir_status = set_working_dir(args[1])
if (new_dir_status === SetDirStatus.NotADirectory) {
term.appendChild(stdout(`cd: "${args[1]}" is not a directory`))
} else if (new_dir_status === SetDirStatus.NotFound) {
term.appendChild(stdout(`cd: The directory "${args[1]}" does not exist`))
}
return true
}