23 lines
629 B
TypeScript
23 lines
629 B
TypeScript
/// <reference lib="dom" />
|
|
// Print all the commands.
|
|
|
|
import { commands } from "@/js/commands"
|
|
|
|
export default function (prefix?: string) {
|
|
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(" ")
|
|
} |