diff --git a/bin/commands.ts b/bin/commands.ts index c143fc3..c328ac2 100644 --- a/bin/commands.ts +++ b/bin/commands.ts @@ -3,6 +3,21 @@ import { commands } from "@/js/commands" -export default function () { - return { html: "
" + Object.keys(commands).map(cmd => `${cmd}`).join("") + "
" } +export default function (prefix?: string) { + let cmds = prefix ? matchingCommands(prefix) : commands + + return { html: "
" + Object.keys(cmds).map(cmd => `${cmd}`).join("") + "
" } +} + + +function matchingCommands(cmd: string): string { + let matched: string[] = [] + console.log(Object.keys(commands)) + for (const command of Object.keys(commands)) { + console.log("cmd->", command) + if (command.startsWith(cmd)) matched.push(command) + } + + + return matched.join(" ") } \ No newline at end of file