fix: accept install platform before subcommand
This commit is contained in:
@@ -32,6 +32,10 @@ type InstallCommandOptions = {
|
|||||||
readonly skipAuth?: boolean
|
readonly skipAuth?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type RootCommandOptions = {
|
||||||
|
readonly platform?: InstallArgs["platform"]
|
||||||
|
}
|
||||||
|
|
||||||
export function resolveInstallArgs(
|
export function resolveInstallArgs(
|
||||||
options: InstallCommandOptions,
|
options: InstallCommandOptions,
|
||||||
invocationName: string | undefined = process.env.OMO_INVOCATION_NAME,
|
invocationName: string | undefined = process.env.OMO_INVOCATION_NAME,
|
||||||
@@ -60,6 +64,7 @@ program
|
|||||||
.description("The ultimate OpenCode plugin - multi-model orchestration, LSP tools, and more")
|
.description("The ultimate OpenCode plugin - multi-model orchestration, LSP tools, and more")
|
||||||
.version(VERSION, "-v, --version", "Show version number")
|
.version(VERSION, "-v, --version", "Show version number")
|
||||||
.helpOption("-h, --help", "Display help for command")
|
.helpOption("-h, --help", "Display help for command")
|
||||||
|
.addOption(new Option("--platform <platform>", "Install target platform: opencode, codex, both").choices(["opencode", "codex", "both"]).hideHelp())
|
||||||
.enablePositionalOptions()
|
.enablePositionalOptions()
|
||||||
|
|
||||||
program
|
program
|
||||||
@@ -98,8 +103,9 @@ Model Providers (Priority: Native > Copilot > OpenCode Zen > Z.ai > Kimi > Verce
|
|||||||
Kimi kimi-for-coding/k2p5 (Sisyphus/Prometheus fallback)
|
Kimi kimi-for-coding/k2p5 (Sisyphus/Prometheus fallback)
|
||||||
Vercel vercel/ models (universal proxy, always last fallback)
|
Vercel vercel/ models (universal proxy, always last fallback)
|
||||||
`)
|
`)
|
||||||
.action(async (options) => {
|
.action(async (options: InstallCommandOptions) => {
|
||||||
const args = resolveInstallArgs(options)
|
const rootOptions = program.opts<RootCommandOptions>()
|
||||||
|
const args = resolveInstallArgs({ ...options, platform: options.platform ?? rootOptions.platform })
|
||||||
const exitCode = await install(args)
|
const exitCode = await install(args)
|
||||||
process.exit(exitCode)
|
process.exit(exitCode)
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -106,4 +106,18 @@ describe("install platform resolution", () => {
|
|||||||
expect(installBlock?.[1]).toContain("--codex-autonomous")
|
expect(installBlock?.[1]).toContain("--codex-autonomous")
|
||||||
expect(installBlock?.[1]).toContain("--no-codex-autonomous")
|
expect(installBlock?.[1]).toContain("--no-codex-autonomous")
|
||||||
})
|
})
|
||||||
|
|
||||||
|
test("defines root --platform so npx can pass it before install", async () => {
|
||||||
|
// given
|
||||||
|
const cliProgramSource = await Bun.file(new URL("./cli-program.ts", import.meta.url)).text()
|
||||||
|
|
||||||
|
// when
|
||||||
|
const rootBlock = cliProgramSource.match(/program\s*\n\s*\.name\("oh-my-opencode"\)([\s\S]*?)\.enablePositionalOptions\(\)/)
|
||||||
|
|
||||||
|
// then
|
||||||
|
expect(rootBlock).not.toBeNull()
|
||||||
|
expect(rootBlock?.[1]).toContain('new Option("--platform <platform>"')
|
||||||
|
expect(rootBlock?.[1]).toContain('.choices(["opencode", "codex", "both"])')
|
||||||
|
expect(rootBlock?.[1]).toContain(".hideHelp()")
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user