Files
oh-my-opencode/src/cli/cli-program.test.ts
T
YeonGyu-Kim ce4b11b0d3 fix(cli): add explicit helpOption configuration for consistent help-flag ordering
Add explicit .helpOption('-h, --help') call to the Commander program configuration so the help option is explicitly defined rather than relying on Commander.js lazy initialization. Add corresponding test to pin the behavior.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-05-25 11:00:37 +09:00

40 lines
1.1 KiB
TypeScript

import { describe, test, expect } from "bun:test"
import { readFile } from "node:fs/promises"
import path from "node:path"
describe("cli-program", () => {
test("install command exposes 'setup' as an alias so the historical install path keeps working", async () => {
// given
const cliProgramSource = await readFile(
path.resolve(import.meta.dir, "cli-program.ts"),
"utf-8",
)
// when
const installBlock = cliProgramSource.match(
/program\s*\n\s*\.command\("install"\)([\s\S]*?)\.action\(/,
)
// then
expect(installBlock).not.toBeNull()
expect(installBlock?.[1]).toContain('.alias("setup")')
})
})
test("program configures explicit '-h, --help' help option for consistent help-flag ordering", async () => {
// given
const cliProgramSource = await readFile(
path.resolve(import.meta.dir, "cli-program.ts"),
"utf-8",
)
// when
const programBlock = cliProgramSource.match(
/program\s*\n((?:\s*\.\w+\([^)]*\)\s*\n?)*)/,
)
// then
expect(programBlock).not.toBeNull()
expect(programBlock?.[1]).toContain('.helpOption("-h, --help", "Display help for command")')
})