diff --git a/src/styles/view.css b/src/styles/view.css index e0f0957..21343e8 100644 --- a/src/styles/view.css +++ b/src/styles/view.css @@ -11,7 +11,6 @@ font-weight: 600; background-color: #161616; - text-wrap: wrap; white-space: pre; padding: 0.5vw; @@ -34,7 +33,7 @@ .window.terminal { left: 1vw; width: 50vw; - background-color: #030303; + text-wrap: wrap; font-variant-ligatures: none; } diff --git a/src/system/commands.tsx b/src/system/commands.tsx index c1354fe..54d67a8 100644 --- a/src/system/commands.tsx +++ b/src/system/commands.tsx @@ -56,10 +56,11 @@ export interface CommandTemplate { info?: CommandInformation; } -const CMD_LS: CommandTemplate = { name: CommandName.ls, allowed_flags: ["l", "a"], params_expected:[0,1], - info: { usage: "ls [-la]... [FILE]...", +const CMD_LS: CommandTemplate = { name: CommandName.ls, allowed_flags: ["l", "a", "A"], params_expected:[0,1], + info: { usage: "ls [OPTIONS]... [FILE]...", description: "List information about the FILEs (the current directory by default).\n"+ "\t-a\tdo not ignore entries starting with .\n"+ + "\t-A\tdo not ignore entries starting with ., except for . and ..\n"+ "\t-l\tuse a long listing format" }} const CMD_PWD: CommandTemplate = { name: CommandName.pwd, allowed_flags: [], params_expected:[0], info: { usage: "pwd", diff --git a/src/system/filetree.tsx b/src/system/filetree.tsx index 97275ce..77adb6b 100644 --- a/src/system/filetree.tsx +++ b/src/system/filetree.tsx @@ -71,6 +71,9 @@ class FileSystemNode { } private getChildFile(filename: string): FileSystemNode | null { + // Temporary hack until I can figure out how to deal with "." and ".." nodes + if (filename === '.') return this; + if (filename === '..') return this.getParent(); return this.children.find((child) => child.getFilename() === filename) || null; } diff --git a/src/system/implementation.tsx b/src/system/implementation.tsx index 5bdd5a1..57f2821 100644 --- a/src/system/implementation.tsx +++ b/src/system/implementation.tsx @@ -55,11 +55,11 @@ export const evaluateCommand = (command: Command, : pwd; if (!dir) { return getNoFileError(command, command.parameters.at(0)!); } - if (!dir.isDirectory) { return getError(command, `Is a`)} + if (!dir.isDirectory) { return getNotFileError(command, command.parameters.at(0)!)} const children = dir.getChildren() .sort((a,b) => a.filename.localeCompare(b.filename)) - .filter((child) => child.filename[0] !== '.' || command.flags.has("a")) + .filter((child) => child.filename[0] !== '.' || command.flags.has("a") || command.flags.has("A")) const filenames = children.map((child) => { let displayName = child.filename; @@ -76,17 +76,24 @@ export const evaluateCommand = (command: Command, return displayName; }); - return filenames.join('\u00A0\u00A0'); // add two spaces inbetween + // Scummy workaround until I can figure out how to actually represent "." and ".." in code + if (command.flags.has("a")) filenames.splice(0, 0, + termColors.primary.formatted + ".", + termColors.primary.formatted + ".." + termColors.default.formatted + ); + + return filenames.join(' '); // add two spaces inbetween } case (CommandName.pwd): { return pwd.getFilepath(); } case (CommandName.cd): { // If no parameters, go to root - if (command.parameters.length == 0) { setPwd(pwd.root); } - + if (command.parameters.length == 0) { + modifyEnvironment({ ...currentEnvironment, dir: pwd.root.filename}); + setPwd(pwd.root); + } else if (command.parameters.length == 1) { const destName = command.parameters[0]; - const dir = (destName === "..") ? pwd.getParent() : pwd.getFileSystemNode(destName); - + const dir = pwd.getFileSystemNode(destName); if (dir === null) { return getNoFileError(command, destName); } else if (!dir.isDirectory) { return getNotDirectoryError(command, destName); } else { diff --git a/src/system/parser.tsx b/src/system/parser.tsx index 184ad92..addf72e 100644 --- a/src/system/parser.tsx +++ b/src/system/parser.tsx @@ -173,7 +173,7 @@ export class Validator { let flag: string = this.prev().content; if (!isFlag(flag)) return get_error_command("Unexpected flag."); // can never be too safe - flag = flag.substring(flag.search(/[a-z]/)); + flag = flag.substring(flag.search(/[a-zA-Z]/)); if (flag === 'h' || flag === 'help') { return { name: CommandName.help, flags: new Set([]), parameters: [cmd_name]}; } @@ -192,8 +192,8 @@ export class Validator { } if (template.params_expected.length != 0 && !(template.params_expected.includes(cmd_params.length))) { - return get_error_command(`Unexpected number of parameters: ${cmd_params.length}. - Expected ${template.params_expected.join(" or ")} parameters.`); + return get_error_command(`Unexpected number of arguments: ${cmd_params.length}, `+ + `Expected ${template.params_expected.join(" or ")}.`); } /** Verifying end of file as we expect */