mirror of
https://gitea.toothfairyai.com/ToothFairyAI/tf_code.git
synced 2026-03-31 14:22:27 +00:00
32 lines
796 B
TypeScript
32 lines
796 B
TypeScript
import { Server } from "../../server/server"
|
|
import { cmd } from "./cmd"
|
|
|
|
export const ServeCommand = cmd({
|
|
command: "serve",
|
|
builder: (yargs) =>
|
|
yargs
|
|
.option("port", {
|
|
alias: ["p"],
|
|
type: "number",
|
|
describe: "port to listen on",
|
|
default: 0,
|
|
})
|
|
.option("hostname", {
|
|
type: "string",
|
|
describe: "hostname to listen on",
|
|
default: "127.0.0.1",
|
|
}),
|
|
describe: "starts a headless opencode server",
|
|
handler: async (args) => {
|
|
const hostname = args.hostname
|
|
const port = args.port
|
|
const server = Server.listen({
|
|
port,
|
|
hostname,
|
|
})
|
|
console.log(`opencode server listening on http://${server.hostname}:${server.port}`)
|
|
await new Promise(() => {})
|
|
await server.stop()
|
|
},
|
|
})
|