1import { plainCliFormatter } from "@/Cli/PlainCliFormatter.ts";
2import * as Context from "effect/Context";
3import * as Option from "effect/Option";
4import { expect, it } from "alchemy-test";
5
6it(
7 "compacts enum flag types and bounds every line",
8 () => {
9 const output = plainCliFormatter({ columns: 80 }).formatHelpDoc({
10 description:
11 "Define, deploy, and operate cloud infrastructure with type-safe Effect programs. " +
12 "This description is deliberately long enough that the default formatter would " +
13 "emit a line wider than eighty columns without wrapping.",
14 usage: "alchemy <subcommand> [flags]",
15 annotations: Context.empty(),
16 flags: [],
17 globalFlags: [
18 {
19 name: "log-level",
20 aliases: [],
21 type: "all|trace|debug|info|warn|warning|error|fatal|none",
22 description: Option.some(
23 "Sets the minimum log level for every command and provider.",
24 ),
25 required: false,
26 },
27 ],
28 subcommands: [
29 {
30 group: undefined,
31 commands: [
32 {
33 name: "deploy",
34 alias: undefined,
35 shortDescription: "Deploy a stack",
36 description: "Deploy a stack",
37 },
38 ],
39 },
40 ],
41 examples: [{ command: "alchemy deploy" }],
42 });
43
44 // The nine-choice enum must not widen the flag column.
45 expect(output).toContain("--log-level all|trace|…");
46 for (const line of output.split("\n")) {
47 expect(line.length <= 80).toBe(true);
48 }
49 },
50 { tags: ["unit", "local"] },
51);