feat: add --context flag for temporary config profile switching#235
Merged
feat: add --context flag for temporary config profile switching#235
Conversation
Adds a --context/-c global flag to temporarily use a different config profile for a single command, similar to kubectl --context. Usage: prime --context user1 sandbox create ... prime -c production pods list The context is only applied for that command and does not persist. Closes #91
pokgak
approved these changes
Dec 3, 2025
Contributor
pokgak
left a comment
There was a problem hiding this comment.
this one a bit confusing because --context need to be explicitly before any subcommands like prime --context local sandbox list and not prime sandbox list --context=local. works but ideally we should be able to put it anywhere after prime.
not a big issue tho so approved.
| raise typer.Exit() | ||
|
|
||
| if context: | ||
| import os |
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.
Summary
--context/-cglobal flag to temporarily use a different config profile for a single commandkubectl --context- allows switching between users/environments without runningprime config useUsage
Implementation
--contextoption to main app callbackPRIME_CONTEXTenv var whichConfigchecks on initpersist=Falseoption toload_environment()for in-memory-only loadingTest plan
prime --context production config viewshows production configprime config viewafter still shows original config (not persisted)prime --context nonexistent ...shows helpful error with available contextsCloses #91
Note
Adds a global
--context/-cflag that temporarily switches the config environment for a single command viaPRIME_CONTEXT, backed byConfig.load_environment(..., persist=False).--context/-coption inprime_cli/main.pyto use a specific config environment per command.production) againstConfig.list_environments()and prints available contexts on error.PRIME_CONTEXTso subcommands inherit the selected environment.PRIME_CONTEXTon init incore/config.pyandload_environment(context, persist=False)for in-memory override.load_environment(name, persist=True|False)to support non-persistent loading forproductionand saved environments, including URL normalization and selective field updates.Written by Cursor Bugbot for commit 580d47c. This will update automatically on new commits. Configure here.