forked from tools/josh
1
0
Fork 0

Implement -l option for ls

Fixes #123.
This commit is contained in:
Florine W. Dekker 2020-09-30 16:50:45 +02:00
parent 1f471acce2
commit 55bcf5c809
Signed by: FWDekker
GPG Key ID: B1B567AF58D6EE0F
4 changed files with 10 additions and 6 deletions

View File

@ -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",

View File

@ -646,19 +646,23 @@ return new Command(
if (input.argc > 1)
streams.out.writeLine(\`<b>\${path}</b>\`);
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 [<b>-a</b> | <b>-A</b> | <b>--all</b>] [<u>directory</u> <u>...</u>]\`,
\`ls [<b>-a</b> | <b>-A</b> | <b>--all</b>] [<b>-l</b> <b>-L</b> <b>--long</b>] [<u>directory</u> <u>...</u>]\`,
\`Displays the files and directories in each <u>directory</u>. 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 <u>directory</u> in order.
Files starting with a <u>.</u> are only shown if the <b>--all</b> option is given, with the exception of ${n}
<u>.</u> and <u>..</u>, which are always shown.\`.trimMultiLines(),
<u>.</u> and <u>..</u>, which are always shown.
Files and directories are separated by a whitespace by default. With the <b>--long</b> option, the separator is ${n}
is changed to the newline character.\`.trimMultiLines(),
new InputValidator()
)`,
"mkdir": /* language=JavaScript */ `\

View File

@ -610,7 +610,7 @@ export class Directory extends Node {
* @param path the path to this node
*/
nameString(name: string, path: Path): string {
return `<a href="#" class="dirLink" onclick="execute('cd ${path.toString(true)}; and ls')">${name}</a>`;
return `<a href="#" class="dirLink" onclick="execute('cd ${path.toString(true)}; and ls -l')">${name}</a>`;
}
visit(path: string,

View File

@ -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");
});