Mixing spaces and tabs, extra semicolons and lonely ifs are now forbidden

This commit is contained in:
BB
2022-03-11 16:32:48 +01:00
parent 372776c94e
commit 5e2ccc71ec
16 changed files with 47 additions and 85 deletions
+2 -6
View File
@@ -68,13 +68,11 @@ export function ParseCommand(command: string): (string | number | boolean)[] {
}
continue;
}
} else {
if (inQuote === ``) {
} else if (inQuote === ``) {
inQuote = `"`;
} else if (inQuote === `"`) {
inQuote = ``;
}
}
} else if (c === "'") {
// Single quotes, same thing as above
if (!escaped && prevChar === " ") {
@@ -88,13 +86,11 @@ export function ParseCommand(command: string): (string | number | boolean)[] {
}
continue;
}
} else {
if (inQuote === ``) {
} else if (inQuote === ``) {
inQuote = `'`;
} else if (inQuote === `'`) {
inQuote = ``;
}
}
} else if (c === " " && inQuote === ``) {
const arg = command.substr(start, i - start);
+1 -3
View File
@@ -179,13 +179,11 @@ export function ls(
i--;
if (!style) {
terminal.print(row);
} else {
if (linked) {
} else if (linked) {
terminal.printRaw(<ClickableScriptRow row={row} prefix={prefix} hostname={server.hostname} />);
} else {
terminal.printRaw(<span style={style}>{row}</span>);
}
}
}
}
+1 -3
View File
@@ -14,11 +14,9 @@ export function unalias(
if (args.length !== 1) {
terminal.error("Incorrect usage of unalias name. Usage: unalias [alias]");
return;
} else {
if (removeAlias(args[0] + "")) {
} else if (removeAlias(args[0] + "")) {
terminal.print(`Removed alias ${args[0]}`);
} else {
terminal.error(`No such alias exists: ${args[0]}`);
}
}
}
+3 -9
View File
@@ -66,28 +66,22 @@ export function tabCompletion(
if (arg === "") {
if (longestStartSubstr === command) {
return allPossibilities;
} else {
if (semiColonIndex === -1) {
} else if (semiColonIndex === -1) {
// No semicolon, so replace the whole command
return longestStartSubstr;
} else {
// Replace only after the last semicolon
return `${oldValue.slice(0, semiColonIndex + 1)} ${longestStartSubstr}`;
}
}
} else {
if (longestStartSubstr === arg) {
} else if (longestStartSubstr === arg) {
// List all possible options
return allPossibilities;
} else {
if (semiColonIndex == -1) {
} else if (semiColonIndex == -1) {
// No semicolon, so replace the whole command
return `${command} ${longestStartSubstr}`;
} else {
// Replace only after the last semicolon
return `${oldValue.slice(0, semiColonIndex + 1)} ${command} ${longestStartSubstr}`;
}
}
}
}
}