feat(cli): add global --stage invocation override - #127
Merged
Conversation
Add `-g` / `--stage` as a global option that overrides the active profile's configured stage for a single invocation. The override retargets the API host and, for `rw auth login`, the WorkOS tenant — nothing else. `config::resolve_profile` gains a `stage_override` parameter so that one function decides the effective stage; `build_ctx` and `config doctor` both inherit it. Profile-resolution errors still fire before any override applies. `AppContext.auth_stage` is deliberately not overridden. It keeps reading the credential-owning profile's stored stage, so token refresh still targets the tenant that issued the stored refresh token. As a consequence, an override crossing the prod/sandbox <-> qa/dev/local tenant boundary sends a token the target rejects and gets a 401; in-tenant hops work. This is accepted behavior, documented in README.md. `check_stage_compatible` rejects the override on `rw auth login` and `rw auth logout`: login mints from the overridden stage's tenant but stores under the profile, which across tenants leaves a token the profile can never refresh. Within a tenant the minted token is identical either way, so the guard forfeits nothing. Known behavior: on `rw config profile add` and `rw config profile set`, `-g` / `--stage` sets the profile's *stored* stage regardless of where it appears on the command line, because clap propagates global argument values bidirectionally across the match tree and both flags share the arg id `stage`. Dropping `global = true` would fix it but would also stop `-g` parsing after the subcommand; a guard is not implementable, since the upward propagation makes the two flag positions indistinguishable through clap's derive API. Documented in README.md, docs/config.md, and skills/rw-skill.md. Refs CL-8
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add
-g/--stageas a global option that overrides the active profile's configured stage for a single invocation. The override retargets the API host and, forrw auth login, the WorkOS tenant — nothing else.config::resolve_profilegains astage_overrideparameter so that one function decides the effective stage;build_ctxandconfig doctorboth inherit it. Profile-resolution errors still fire before any override applies.AppContext.auth_stageis deliberately not overridden. It keeps reading the credential-owning profile's stored stage, so token refresh still targets the tenant that issued the stored refresh token. As a consequence, an override crossing the prod/sandbox <-> qa/dev/local tenant boundary sends a token the target rejects and gets a 401; in-tenant hops work. This is accepted behavior, documented in README.md.check_stage_compatiblerejects the override onrw auth loginandrw auth logout: login mints from the overridden stage's tenant but stores under the profile, which across tenants leaves a token the profile can never refresh. Within a tenant the minted token is identical either way, so the guard forfeits nothing.Known behavior: on
rw config profile addandrw config profile set,-g/--stagesets the profile's stored stage regardless of where it appears on the command line, because clap propagates global argument values bidirectionally across the match tree and both flags share the arg idstage. Droppingglobal = truewould fix it but would also stop-gparsing after the subcommand; a guard is not implementable, since the upward propagation makes the two flag positions indistinguishable through clap's derive API. Documented in README.md, docs/config.md, and skills/rw-skill.md.Resolves CL-8