diff --git a/bin/commands.ts b/bin/commands.ts
index c328ac2..5cf3b49 100644
--- a/bin/commands.ts
+++ b/bin/commands.ts
@@ -1,23 +1,19 @@
-///
-// Print all the commands.
+// Print all the commands, or a subset.
-import { commands } from "@/js/commands"
+import { commands } from "@/commands"
-export default function (prefix?: string) {
- let cmds = prefix ? matchingCommands(prefix) : commands
+export default async function (prefix?: string) {
+ let cmds = prefix ? await matchingCommands(prefix) : Object.keys(await commands())
- return { html: "
" + Object.keys(cmds).map(cmd => `
${cmd}`).join("") + "
" }
+ return { html: "" + cmds.map(cmd => `
${cmd}`).join("") + "
" }
}
-function matchingCommands(cmd: string): string {
+async function matchingCommands(cmd: string): Promise {
let matched: string[] = []
- console.log(Object.keys(commands))
- for (const command of Object.keys(commands)) {
- console.log("cmd->", command)
+
+ for (const command of Object.keys(await commands()))
if (command.startsWith(cmd)) matched.push(command)
- }
-
- return matched.join(" ")
+ return matched
}
\ No newline at end of file
diff --git a/bin/help.ts b/bin/help.ts
index dfcacb6..b0e2f2c 100644
--- a/bin/help.ts
+++ b/bin/help.ts
@@ -2,13 +2,15 @@
//
// (Hopefully.)
-import { commandPath, commands } from "@/commands"
+import { commandPath } from "@/commands"
+import type { CommandOutput } from "@/shared/types"
+import commands from "./commands"
-export default async function (cmd: string): Promise {
+export default async function (cmd: string): Promise {
if (!cmd) return "usage: help "
const path = commandPath(cmd)
- if (!path) { return matchingCommands(cmd) }
+ if (!path) return await commands(cmd)
const code = (await Bun.file(path).text()).split("\n")
let docs = []
@@ -26,12 +28,3 @@ export default async function (cmd: string): Promise {
return docs.join("\n")
}
-
-async function matchingCommands(cmd: string): Promise {
- let matched: string[] = []
- for (const command of Object.keys(await commands())) {
- if (command.startsWith(cmd)) matched.push(command)
- }
-
- return matched.join(" ")
-}
\ No newline at end of file
diff --git a/bin/session.tsx b/bin/session.tsx
index fb3979c..8155c0e 100644
--- a/bin/session.tsx
+++ b/bin/session.tsx
@@ -1,3 +1,5 @@
+// Print information about the current session.
+
import { sessionGet } from "@/session"
import { highlightToHTML } from "../lib/highlight"