nose-pluto/bin/commands.ts
Chris Wanstrath 415cbd0ccd wip
2025-10-07 18:42:33 -07:00

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(" ")
}