Open History to see the last commit
1import * as Effect from "effect/Effect";
2import { Command, GlobalFlag } from "effect/unstable/cli";
3
4import { ServerConfig, type StartupPresentation } from "../config.ts";
5import { runServer } from "../server.ts";
6import { type CliServerFlags, resolveServerConfig, sharedServerCommandFlags } from "./config.ts";
7
8export const runServerCommand = (
9 flags: CliServerFlags,
10 options?: {
11 readonly startupPresentation?: StartupPresentation;
12 readonly forceAutoBootstrapProjectFromCwd?: boolean;
13 },
14) =>
15 Effect.gen(function* () {
16 const logLevel = yield* GlobalFlag.LogLevel;
17 const config = yield* resolveServerConfig(flags, logLevel, options);
18 return yield* runServer.pipe(Effect.provideService(ServerConfig, config));
19 });
20
21export const startCommand = Command.make("start", { ...sharedServerCommandFlags }).pipe(
22 Command.withDescription("Run the T3 Code server."),
23 Command.withHandler((flags) => runServerCommand(flags)),
24);
25
26export const serveCommand = Command.make("serve", { ...sharedServerCommandFlags }).pipe(
27 Command.withDescription(
28 "Run the T3 Code server without opening a browser and print headless pairing details.",
29 ),
30 Command.withHandler((flags) =>
31 runServerCommand(flags, {
32 startupPresentation: "headless",
33 forceAutoBootstrapProjectFromCwd: false,
34 }),
35 ),
36);