From 55bcf5c809678850a4f753b48e0cc2cf0a0bbf0b Mon Sep 17 00:00:00 2001 From: "Felix W. Dekker" Date: Wed, 30 Sep 2020 16:50:45 +0200 Subject: [PATCH] Implement -l option for ls Fixes #123. --- package.json | 2 +- src/main/js/Commands.ts | 10 +++++++--- src/main/js/FileSystem.ts | 2 +- src/main/js/Main.ts | 2 +- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index ce5f036..61fb68f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "fwdekker.com", - "version": "0.38.3", + "version": "0.38.4", "description": "The source code of [my personal website](https://fwdekker.com/).", "author": "Felix W. Dekker", "browser": "dist/bundle.js", diff --git a/src/main/js/Commands.ts b/src/main/js/Commands.ts index 7d2f390..5072fe4 100644 --- a/src/main/js/Commands.ts +++ b/src/main/js/Commands.ts @@ -646,19 +646,23 @@ return new Command( if (input.argc > 1) streams.out.writeLine(\`\${path}\`); - streams.out.writeLine(dirList.concat(fileList).join("\\n")); + streams.out.writeLine(dirList.concat(fileList) + .join(input.hasAnyOption("-l", "-L", "--long") ? "\\n" : " ")); return ExitCode.OK; }) .reduce((acc, exitCode) => exitCode === ExitCode.OK ? acc : exitCode); }, \`list directory contents\`, - \`ls [-a | -A | --all] [directory ...]\`, + \`ls [-a | -A | --all] [-l -L --long] [directory ...]\`, \`Displays the files and directories in each directory. If no directory is given, the files and ${n} directories in the current working directory are shown. If more than one directory is given, the files and ${n} directories are shown for each given directory in order. Files starting with a . are only shown if the --all option is given, with the exception of ${n} - . and .., which are always shown.\`.trimMultiLines(), + . and .., which are always shown. + + Files and directories are separated by a whitespace by default. With the --long option, the separator is ${n} + is changed to the newline character.\`.trimMultiLines(), new InputValidator() )`, "mkdir": /* language=JavaScript */ `\ diff --git a/src/main/js/FileSystem.ts b/src/main/js/FileSystem.ts index 7708a7a..624ce35 100644 --- a/src/main/js/FileSystem.ts +++ b/src/main/js/FileSystem.ts @@ -610,7 +610,7 @@ export class Directory extends Node { * @param path the path to this node */ nameString(name: string, path: Path): string { - return `${name}`; + return `${name}`; } visit(path: string, diff --git a/src/main/js/Main.ts b/src/main/js/Main.ts index b058016..b8415b8 100644 --- a/src/main/js/Main.ts +++ b/src/main/js/Main.ts @@ -73,5 +73,5 @@ addOnLoad(async () => { // @ts-ignore: Ugly hack to execute it anyway if (window.terminal.shell.environment.get("user") !== "") - window.execute("ls"); + window.execute("ls -l"); });