This commit is contained in:
Chris Wanstrath 2025-10-07 18:42:33 -07:00
parent 2d7a5d157b
commit 415cbd0ccd

View File

@ -3,6 +3,21 @@
import { commands } from "@/js/commands" import { commands } from "@/js/commands"
export default function () { export default function (prefix?: string) {
return { html: "<div>" + Object.keys(commands).map(cmd => `<a href="#help ${cmd}">${cmd}</a>`).join("") + "</div>" } let cmds = prefix ? matchingCommands(prefix) : commands
return { html: "<div>" + Object.keys(cmds).map(cmd => `<a href="#help ${cmd}">${cmd}</a>`).join("") + "</div>" }
}
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(" ")
} }