import { startHttpServer } from "../../http/server.js"; import { numberOption, stringOption } from "../parser.js"; import type { CliParsedArgs, CliResult, CliRuntime } from "../types.js"; export async function handleHttpCommand( parsed: CliParsedArgs, runtime: CliRuntime ): Promise { const port = numberOption(parsed.options, ["port", "p"]); const host = stringOption(parsed.options, ["host", "h"]); const server = await startHttpServer({ port, host, silent: runtime.jsonMode }); // Handle graceful shutdown const shutdown = () => { server.close(() => { process.exit(0); }); }; process.on("SIGINT", shutdown); process.on("SIGTERM", shutdown); // Keep alive in foreground await new Promise(() => {}); return { stdout: "", stderr: "", exitCode: 0 }; }