wip
This commit is contained in:
parent
2d7a5d157b
commit
415cbd0ccd
|
|
@ -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(" ")
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue
Block a user