forked from tools/josh
parent
bc17640f42
commit
8dfcc7f6af
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "fwdekker.com",
|
||||
"version": "0.33.4",
|
||||
"version": "0.33.5",
|
||||
"description": "The source code of [my personal website](https://fwdekker.com/).",
|
||||
"author": "Felix W. Dekker",
|
||||
"browser": "bundle.js",
|
||||
|
|
|
@ -295,7 +295,8 @@ const n = "\\\\\\";
|
|||
* @return the script contents of the binaries in the `/bin` directory
|
||||
*/
|
||||
export const commandBinaries: { [key: string]: string } = {
|
||||
"and": `return new Command(
|
||||
"and": `\
|
||||
return new Command(
|
||||
(input, streams) => {
|
||||
const previousStatus = Number(josh.environment.getOrDefault("status", "0"));
|
||||
if (previousStatus !== 0)
|
||||
|
@ -315,7 +316,8 @@ export const commandBinaries: { [key: string]: string } = {
|
|||
\`.trimMultiLines(),
|
||||
new InputValidator({minArgs: 1})
|
||||
)`,
|
||||
"cat": `return new Command(
|
||||
"cat": `\
|
||||
return new Command(
|
||||
(input, streams) => {
|
||||
return input.args
|
||||
.map(arg => Path.interpret(josh.environment.get("cwd"), arg))
|
||||
|
@ -341,12 +343,12 @@ export const commandBinaries: { [key: string]: string } = {
|
|||
\`cat [<b>-e</b> | <b>--escape-html</b>] <u>file</u> <u>...</u>\`,
|
||||
\`Reads files sequentially, writing them to the standard output.
|
||||
|
||||
If the file contains valid HTML, it will be displayed as such by default. If the <b>--escape-html</b> ${n}
|
||||
option is given, special HTML characters are escaped and the raw text contents can be inspected.${n}
|
||||
\`.trimMultiLines(),
|
||||
If the file contains valid HTML, it will be displayed as such by default. If the <b>--escape-html</b> option is ${n}
|
||||
given, special HTML characters are escaped and the raw text contents can be inspected.\`.trimMultiLines(),
|
||||
new InputValidator({minArgs: 1})
|
||||
)`,
|
||||
"cd": `return new Command(
|
||||
"cd": `\
|
||||
return new Command(
|
||||
(input, streams) => {
|
||||
if (input.argc === 0) {
|
||||
josh.environment.set("cwd", josh.environment.get("home"));
|
||||
|
@ -364,11 +366,12 @@ export const commandBinaries: { [key: string]: string } = {
|
|||
},
|
||||
\`change directory\`,
|
||||
\`cd [<u>directory</u>]\`,
|
||||
\`Changes the current working directory to <u>directory</u>. If no <u>directory</u> is supplied, the ${n}
|
||||
current working directory is changed to the current user's home directory.\`.trimMultiLines(),
|
||||
\`Changes the current working directory to <u>directory</u>. If no <u>directory</u> is supplied, the current ${n}
|
||||
working directory is changed to the current user's home directory.\`.trimMultiLines(),
|
||||
new InputValidator({maxArgs: 1})
|
||||
)`,
|
||||
"clear": `return new Command(
|
||||
"clear": `\
|
||||
return new Command(
|
||||
(input, streams) => {
|
||||
streams.out.write(EscapeCharacters.Escape + EscapeCharacters.Clear);
|
||||
return 0;
|
||||
|
@ -378,7 +381,8 @@ export const commandBinaries: { [key: string]: string } = {
|
|||
\`Clears all previous terminal output.\`,
|
||||
new InputValidator({maxArgs: 0})
|
||||
)`,
|
||||
"cp": `return new Command(
|
||||
"cp": `\
|
||||
return new Command(
|
||||
(input, streams) => {
|
||||
let mappings;
|
||||
try {
|
||||
|
@ -407,17 +411,18 @@ export const commandBinaries: { [key: string]: string } = {
|
|||
\`copy files\`,
|
||||
\`cp [<b>-r</b> | <b>-R</b> | <b>--recursive</b>] <u>source</u> <u>target file</u>
|
||||
cp [<b>-r</b> | <b>-R</b> | <b>--recursive</b>] <u>source</u> <u>...</u> <u>target directory</u>\`,
|
||||
\`In its first form, <u>source</u> is copied to <u>target file</u>. This form is used if there is no file ${n}
|
||||
or directory at <u>target file</u> beforehand.
|
||||
\`In its first form, <u>source</u> is copied to <u>target file</u>. This form is used if there is no file or ${n}
|
||||
directory at <u>target file</u> beforehand.
|
||||
|
||||
In its second form, all <u>source</u> files are copied into <u>target directory</u>, which must be a ${n}
|
||||
pre-existing directory. The file names of the <u>source</u> files are retained.
|
||||
|
||||
In both forms, <u>source</u> files are not copied if they are directories and the <b>-R</b> option is not ${n}
|
||||
given.\`.trimMultiLines(),
|
||||
In both forms, <u>source</u> files are not copied if they are directories and the <b>-R</b> option is not given.${n}
|
||||
\`.trimMultiLines(),
|
||||
new InputValidator({minArgs: 2})
|
||||
)`,
|
||||
"echo": `return new Command(
|
||||
"echo": `\
|
||||
return new Command(
|
||||
(input, streams) => {
|
||||
const message = input.args.join(" ").replace("hunter2", "*******");
|
||||
|
||||
|
@ -435,7 +440,8 @@ export const commandBinaries: { [key: string]: string } = {
|
|||
Unless the <b>--newline</b> parameter is given, a newline is appended to the end.\`.trimMultiLines(),
|
||||
new InputValidator()
|
||||
)`,
|
||||
"exit": `return new Command(
|
||||
"exit": `\
|
||||
return new Command(
|
||||
(input, streams) => {
|
||||
josh.environment.set("user", "");
|
||||
return 0;
|
||||
|
@ -445,7 +451,8 @@ export const commandBinaries: { [key: string]: string } = {
|
|||
\`Closes the terminal session.\`,
|
||||
new InputValidator({maxArgs: 0})
|
||||
)`,
|
||||
"help": `return new Command(
|
||||
"help": `\
|
||||
return new Command(
|
||||
(input, streams) => {
|
||||
if (input.argc > 0) {
|
||||
return input.args
|
||||
|
@ -513,7 +520,8 @@ export const commandBinaries: { [key: string]: string } = {
|
|||
If no commands are given, a list of all commands is shown.\`.trimMultiLines(),
|
||||
new InputValidator()
|
||||
)`,
|
||||
"hier": `return new DocOnlyCommand(
|
||||
"hier": `\
|
||||
return new DocOnlyCommand(
|
||||
\`description of the file system hierarchy\`,
|
||||
\`A typical josh system has, among others, the following directories:
|
||||
|
||||
|
@ -529,7 +537,8 @@ export const commandBinaries: { [key: string]: string } = {
|
|||
|
||||
<u>/root</u> The home directory of the root user.\`.trimMultiLines()
|
||||
)`,
|
||||
"ls": `return new Command(
|
||||
"ls": `\
|
||||
return new Command(
|
||||
(input, streams) => {
|
||||
return (input.argc === 0 ? [""] : input.args)
|
||||
.map(arg => Path.interpret(josh.environment.get("cwd"), arg))
|
||||
|
@ -587,7 +596,8 @@ export const commandBinaries: { [key: string]: string } = {
|
|||
<u>.</u> and <u>..</u>, which are always shown.\`.trimMultiLines(),
|
||||
new InputValidator()
|
||||
)`,
|
||||
"mkdir": `return new Command(
|
||||
"mkdir": `\
|
||||
return new Command(
|
||||
(input, streams) => {
|
||||
return input.args
|
||||
.map(arg => Path.interpret(josh.environment.get("cwd"), arg))
|
||||
|
@ -606,12 +616,12 @@ export const commandBinaries: { [key: string]: string } = {
|
|||
\`mkdir [<b>-p</b> | <b>--parents</b>] <u>directory</u> <u>...</u>\`,
|
||||
\`Creates the directories given by <u>directory</u>.
|
||||
|
||||
If more than one <u>directory</u> is given, the directories are created in the order they are given in. If ${n}
|
||||
the <b>--parents</b> option is given, parent directories that do not exist are created as well.${n}
|
||||
\`.trimMultiLines(),
|
||||
If more than one <u>directory</u> is given, the directories are created in the order they are given in. If the ${n}
|
||||
<b>--parents</b> option is given, parent directories that do not exist are created as well.\`.trimMultiLines(),
|
||||
new InputValidator({minArgs: 1})
|
||||
)`,
|
||||
"mv": `return new Command(
|
||||
"mv": `\
|
||||
return new Command(
|
||||
(input, streams) => {
|
||||
let mappings;
|
||||
try {
|
||||
|
@ -646,7 +656,8 @@ export const commandBinaries: { [key: string]: string } = {
|
|||
pre-existing directory. The file names of the <u>source</u> files are retained.\`.trimMultiLines(),
|
||||
new InputValidator({minArgs: 2})
|
||||
)`,
|
||||
"not": `return new Command(
|
||||
"not": `\
|
||||
return new Command(
|
||||
(input, streams) => {
|
||||
return Number(!josh.interpreter.execute(
|
||||
InputParser.create(josh.environment, josh.fileSystem).parseCommand(input.args),
|
||||
|
@ -655,11 +666,12 @@ export const commandBinaries: { [key: string]: string } = {
|
|||
},
|
||||
\`execute command and invert status code\`,
|
||||
\`not <u>command</u>\`,
|
||||
\`Executes <u>command</u> with its associated options and arguments and inverts its exit code. More ${n}
|
||||
precisely, the exit code is set to 0 if it was non-zero, and is set to 1 otherwise.\`.trimMultiLines(),
|
||||
\`Executes <u>command</u> with its associated options and arguments and inverts its exit code. More precisely, ${n}
|
||||
the exit code is set to 0 if it was non-zero, and is set to 1 otherwise.\`.trimMultiLines(),
|
||||
new InputValidator({minArgs: 1})
|
||||
)`,
|
||||
"open": `return new Command(
|
||||
"open": `\
|
||||
return new Command(
|
||||
(input, streams) => {
|
||||
return input.args
|
||||
.map(it => Path.interpret(josh.environment.get("cwd"), it))
|
||||
|
@ -679,15 +691,16 @@ export const commandBinaries: { [key: string]: string } = {
|
|||
},
|
||||
\`open web pages\`,
|
||||
\`open [<b>-b</b> | <b>--blank</b>] <u>file</u> <u>...</u>\`,
|
||||
\`Opens the web pages linked to by <u>file</u>. The first <u>file</u> is opened in this tab and the ${n}
|
||||
subsequent <u>file</u>s are opened in new tabs. If <b>--blank</b> is set, the first <u>file</u> is opened ${n}
|
||||
in a new tab as well.
|
||||
\`Opens the web pages linked to by <u>file</u>. The first <u>file</u> is opened in this tab and the subsequent ${n}
|
||||
<u>file</u>s are opened in new tabs. If <b>--blank</b> is set, the first <u>file</u> is opened in a new tab as ${n}
|
||||
well.
|
||||
|
||||
If this command is executed inside of a standalone app instead of a browser, every <u>file</u> is opened in ${n}
|
||||
a tab regardless of whether <b>--blank</b> is given.\`.trimMultiLines(),
|
||||
If this command is executed inside of a standalone app instead of a browser, every <u>file</u> is opened in a ${n}
|
||||
tab regardless of whether <b>--blank</b> is given.\`.trimMultiLines(),
|
||||
new InputValidator({minArgs: 1})
|
||||
)`,
|
||||
"or": `return new Command(
|
||||
"or": `\
|
||||
return new Command(
|
||||
(input, streams) => {
|
||||
const previousStatus = Number(josh.environment.getOrDefault("status", "0"));
|
||||
if (previousStatus === 0)
|
||||
|
@ -703,11 +716,11 @@ export const commandBinaries: { [key: string]: string } = {
|
|||
\`Executes <u>command</u> with its associated options and arguments if and only if the status code of the ${n}
|
||||
previously-executed command is not 0.
|
||||
|
||||
The exit code is retained if it was zero, and is changed to that of <u>command</u> otherwise.${n}
|
||||
\`.trimMultiLines(),
|
||||
The exit code is retained if it was zero, and is changed to that of <u>command</u> otherwise.\`.trimMultiLines(),
|
||||
new InputValidator({minArgs: 1})
|
||||
)`,
|
||||
"poweroff": `return new Command(
|
||||
"poweroff": `\
|
||||
return new Command(
|
||||
(input, streams) => {
|
||||
const userName = josh.environment.get("user");
|
||||
if (userName === "") {
|
||||
|
@ -735,7 +748,8 @@ export const commandBinaries: { [key: string]: string } = {
|
|||
\`Automated shutdown procedure to nicely notify users when the system is shutting down.\`,
|
||||
new InputValidator({maxArgs: 0})
|
||||
)`,
|
||||
"pwd": `return new Command(
|
||||
"pwd": `\
|
||||
return new Command(
|
||||
(input, streams) => {
|
||||
streams.out.writeLine(josh.environment.get("cwd") || "");
|
||||
return 0;
|
||||
|
@ -745,7 +759,8 @@ export const commandBinaries: { [key: string]: string } = {
|
|||
\`Displays the current working directory.\`,
|
||||
new InputValidator({maxArgs: 0})
|
||||
)`,
|
||||
"rm": `return new Command(
|
||||
"rm": `\
|
||||
return new Command(
|
||||
(input, streams) => {
|
||||
return input.args
|
||||
.map(arg => Path.interpret(josh.environment.get("cwd"), arg))
|
||||
|
@ -782,18 +797,19 @@ export const commandBinaries: { [key: string]: string } = {
|
|||
\`remove file\`,
|
||||
\`rm [<b>-f</b> | <b>--force</b>] [<b>-r</b> | <b>-R</b> | <b>--recursive</b>] ${n}
|
||||
[<b>--no-preserve-root</b>] <u>file</u> <u>...</u>\`.trimMultiLines(),
|
||||
\`Removes each given <u>file</u>. If more than one <u>file</u> is given, they are removed in the order they ${n}
|
||||
are given in.
|
||||
\`Removes each given <u>file</u>. If more than one <u>file</u> is given, they are removed in the order they are ${n}
|
||||
given in.
|
||||
|
||||
If <b>--force</b> is set, no warning is given if a file could not be removed.
|
||||
|
||||
If <b>--recursive</b> is set, files and directories are removed recursively; without this option ${n}
|
||||
directories cannot be removed.
|
||||
If <b>--recursive</b> is set, files and directories are removed recursively; without this option directories ${n}
|
||||
cannot be removed.
|
||||
|
||||
Unless <b>--no-preserve-root</b> is set, the root directory cannot be removed.\`.trimMultiLines(),
|
||||
new InputValidator({minArgs: 1})
|
||||
)`,
|
||||
"rmdir": `return new Command(
|
||||
"rmdir": `\
|
||||
return new Command(
|
||||
(input, streams) => {
|
||||
return input.args
|
||||
.map(arg => Path.interpret(josh.environment.get("cwd"), arg))
|
||||
|
@ -828,7 +844,8 @@ export const commandBinaries: { [key: string]: string } = {
|
|||
order they are given in. Non-empty directories will not be removed.\`.trimMultiLines(),
|
||||
new InputValidator({minArgs: 1})
|
||||
)`,
|
||||
"set": `return new Command(
|
||||
"set": `\
|
||||
return new Command(
|
||||
(input, streams) => {
|
||||
try {
|
||||
if (input.argc === 1)
|
||||
|
@ -848,7 +865,8 @@ export const commandBinaries: { [key: string]: string } = {
|
|||
variable is cleared. Read-only variables cannot be set.\`.trimMultiLines(),
|
||||
new InputValidator({minArgs: 1, maxArgs: 2})
|
||||
)`,
|
||||
"touch": `return new Command(
|
||||
"touch": `\
|
||||
return new Command(
|
||||
(input, streams) => {
|
||||
return input.args
|
||||
.map(arg => Path.interpret(josh.environment.get("cwd"), arg))
|
||||
|
@ -865,11 +883,12 @@ export const commandBinaries: { [key: string]: string } = {
|
|||
},
|
||||
\`change file timestamps\`,
|
||||
\`touch <u>file</u> <u>...</u>\`,
|
||||
\`Update the access and modification times of each <u>file</u> to the current time. If a <u>file</u> does ${n}
|
||||
not exist, it is created.\`.trimMultiLines(),
|
||||
\`Update the access and modification times of each <u>file</u> to the current time. If a <u>file</u> does not ${n}
|
||||
exist, it is created.\`.trimMultiLines(),
|
||||
new InputValidator({minArgs: 1})
|
||||
)`,
|
||||
"useradd": `return new Command(
|
||||
"useradd": `\
|
||||
return new Command(
|
||||
(input, streams) => {
|
||||
if (josh.userList.has(input.args[0])) {
|
||||
streams.err.writeLine(\`useradd: User '\${input.args[0]}' already exists.\`);
|
||||
|
@ -910,7 +929,8 @@ export const commandBinaries: { [key: string]: string } = {
|
|||
If no <u>home</u> is given, it defaults to "/home/<u>name</u>".\`.trimMultiLines(),
|
||||
new InputValidator({minArgs: 2, maxArgs: 4})
|
||||
)`,
|
||||
"userdel": `return new Command(
|
||||
"userdel": `\
|
||||
return new Command(
|
||||
(input, streams) => {
|
||||
if (!josh.userList.has(input.args[0])) {
|
||||
streams.err.writeLine(\`userdel: Could not delete non-existent user '\${input.args[0]}'.\`);
|
||||
|
@ -930,7 +950,8 @@ export const commandBinaries: { [key: string]: string } = {
|
|||
\`Deletes the user with the given <u>name</u>.\`.trimMultiLines(),
|
||||
new InputValidator({minArgs: 1, maxArgs: 1})
|
||||
)`,
|
||||
"usermod": `return new Command(
|
||||
"usermod": `\
|
||||
return new Command(
|
||||
(input, streams) => {
|
||||
let user = josh.userList.get(input.args[0]);
|
||||
if (user === undefined) {
|
||||
|
@ -966,11 +987,12 @@ export const commandBinaries: { [key: string]: string } = {
|
|||
[<b>-h</b>/<b>--home</b>=<u>home</u>] ${n}
|
||||
[<b>-d</b>/<b>--description</b>=<u>description</u>] ${n}
|
||||
<u>name</u>\`.trimMultiLines(),
|
||||
\`Modifies the user with the given <u>name</u>. See the "useradd" command for more information on the ${n}
|
||||
fields that can be modified.\`.trimMultiLines(),
|
||||
\`Modifies the user with the given <u>name</u>. See the "useradd" command for more information on the fields ${n}
|
||||
that can be modified.\`.trimMultiLines(),
|
||||
new InputValidator({minArgs: 1, maxArgs: 1})
|
||||
)`,
|
||||
"whoami": `return new Command(
|
||||
"whoami": `\
|
||||
return new Command(
|
||||
(input, streams) => {
|
||||
const user = josh.userList.get(josh.environment.get("user"));
|
||||
if (user === undefined) {
|
||||
|
|
Loading…
Reference in New Issue