env

Switch the active environment for your project.

The switch env command changes the default environment in your local project configuration.

Usage#

redenv switch env [--env <environment>]

Options#

FlagDescription
-e, --env <env>Specify environment (interactive selection if omitted)

Examples#

Switch interactively#

redenv switch env

Switch to specific environment#

redenv switch env --env production
# or
redenv switch env -e staging

Interactive Flow#

The selector shows all existing environments plus an option to create a new one:

$ redenv switch env

? Select environment:
 development
  staging
  production
  New environment

 Switched to 'staging' environment.

Creating a New Environment#

Select "New environment" to create one on the fly:

$ redenv switch env

? Select environment: New environment
? Enter environment name: qa

 Switched to 'qa' environment.

Warning

Switching to a new environment only updates your local config file. The environment is not created in the remote store until you add a secret to it. Until then, the environment exists only in redenv.config.ts.

What Changes#

The command updates your local redenv.config.ts:

redenv.config.ts
import { defineConfig } from "@redenv/core";

export default defineConfig({
  name: "my-app",
  environment: "staging", // Changed from "development"
});

This affects all subsequent commands that don't specify --env.

  • register - Set initial environment
  • list - View secrets in current environment
  • diff - Compare environments
  • clone - Copy secrets between environments