Files
OmniRoute/tests/unit/cli
ataozkn 1ac086954a fix(cli): let setup --api-key reach the provider setup path (#10613)
* fix(cli): let setup --api-key reach the provider setup path

`bin/cli/program.mjs` declares a program-level `--api-key` (the OmniRoute server
key) and `bin/cli/commands/setup.mjs` declares its own `--api-key` (the provider
key). Commander binds the value to the program-level option, so the subcommand's
`opts.apiKey` was always `undefined` and

    omniroute setup --non-interactive --add-provider \
      --provider openrouter --api-key sk-...

aborted with "Provider API key is required. Pass --api-key or OMNIROUTE_API_KEY."
— naming the very flag that had just been passed. The documented headless setup
path was unusable; the only way in was `omniroute keys add`.

Fall back to the program-level value in a small exported helper. This also makes
`OMNIROUTE_API_KEY` satisfy the provider key, which the error message already
promised (that env var feeds the program-level option).

Tests cover the real Commander flag shape, the env-var path, and precedence when
both are supplied.

* chore(changelog): use the real PR number for the fragment
2026-08-18 10:53:14 -03:00
..