First REPL mock

This commit is contained in:
2021-12-14 23:08:18 +01:00
parent 1335d28dab
commit d6bd11f65e
5 changed files with 86 additions and 2 deletions

7
lib/commands.ts Normal file
View File

@ -0,0 +1,7 @@
const commandList = ["about", "navigate", "external", "help", "ed", "nano"]
export function commandCompletion(input: string): string {
if (input === "") return "";
const candidates = commandList.map((cmd) => [cmd.substring(0, input.length), cmd]).filter((cmd) => cmd[0] === input);
return candidates.length > 0 ? candidates[0][1] : "";
}