tctx makes it fast and easy to switch between Temporal clusters when running tctl commands.
Build from source using go install:
go install github.com/jlegrone/tctx@latest$ tctx add -c localhost --namespace default --address localhost:7233
Context "localhost" modified.
Active namespace is "default".$ tctx exec -- tctl cluster health
temporal.api.workflowservice.v1.WorkflowService: SERVING$ tctx list
NAME ADDRESS NAMESPACE STATUS
localhost localhost:7233 default active
production temporal-production.example.com:443 myapp
staging temporal-staging.example.com:443 myapp$ tctx use -c production
Context "production" modified.
Active namespace is "myapp".tctx sets standard Temporal CLI environment variables before executing a subcommand with tctx exec.
Any CLI tool (not just tctl) can be used in conjunction with tctx if it leverages these environment variables.
To view all environment variables set for the current context, run
tctx exec -- printenv | grep TEMPORAL_CLIBy default tctx exec uses the active context. The active context is set by the last tctx use or tctx add command.
You can override the active context by adding a context flag
tctx exec -c <context> -- <command>Typing tctx exec -- tctl is a lot of effort. It's possible to define an alias to make this easier.
alias tctl="tctx exec -- tctl"