From 8187b1da914ef6e4b18458b719df296e0595cffd Mon Sep 17 00:00:00 2001 From: Carlos Monastyrski Date: Thu, 17 Jul 2025 06:58:34 -0300 Subject: [PATCH 1/2] Updated CLI export doc to document the new --output-file behavior --- docs/cli/commands/export.mdx | 54 +++++++++++++++++++++++++++++------- 1 file changed, 44 insertions(+), 10 deletions(-) diff --git a/docs/cli/commands/export.mdx b/docs/cli/commands/export.mdx index 6711903ec..076d6d917 100644 --- a/docs/cli/commands/export.mdx +++ b/docs/cli/commands/export.mdx @@ -10,6 +10,7 @@ infisical export [options] ## Description Export environment variables from the platform into a file format. +By default, secrets are saved to `.env` for dotenv formats or `secrets.{format}` for other formats in the current directory. ## Subcommands & flags @@ -19,20 +20,29 @@ Export environment variables from the platform into a file format. ```bash $ infisical export -# Export variables to a .env file -infisical export > .env +# Export variables to .env file (default behavior) +infisical export -# Export variables to a .env file (with export keyword) -infisical export --format=dotenv-export > .env +# Export variables to .env file with explicit format +infisical export --format=dotenv -# Export variables to a CSV file -infisical export --format=csv > secrets.csv +# Export variables to .env file (with export keyword) +infisical export --format=dotenv-export -# Export variables to a JSON file -infisical export --format=json > secrets.json +# Export variables to secrets.csv file +infisical export --format=csv -# Export variables to a YAML file -infisical export --format=yaml > secrets.yaml +# Export variables to secrets.json file +infisical export --format=json + +# Export variables to secrets.yaml file +infisical export --format=yaml + +# Export to custom file path +infisical export --format=json --output-file=./config/prod-secrets.json + +# Export to directory (uses default filename) +infisical export --format=yaml --output-file=./secrets/ # Render secrets using a custom template file infisical export --template= @@ -73,6 +83,30 @@ infisical export --template= ### flags + + The path to write the output file to. Can be a full file path, directory, or filename. + + ```bash + # Export to specific file + infisical export --format=json --output-file=secrets.json + + # Export to directory (uses default filename based on format) + infisical export --format=yaml --output-file=./config/ + + # Export with full path + infisical export --format=csv --output-file=/home/user/secrets/prod.csv + + # Export with home directory expansion + infisical export --format=json --output-file=~/secrets/prod.json + ``` + + **Default behavior when not specified:** + - For `dotenv` and `dotenv-export` formats: defaults to `.env` + - For other formats: defaults to `secrets.{format}` (e.g., `secrets.json`, `secrets.csv`) + - All defaults save to the current working directory + + + The `--template` flag specifies the path to the template file used for rendering secrets. When using templates, you can omit the other format flags. From 350afee45efc4dd0f38f431b04b7541f829d2150 Mon Sep 17 00:00:00 2001 From: Carlos Monastyrski Date: Thu, 17 Jul 2025 10:00:40 -0300 Subject: [PATCH 2/2] Updated cli export doc --- docs/cli/commands/export.mdx | 68 +++++++++++++++++------------------- 1 file changed, 32 insertions(+), 36 deletions(-) diff --git a/docs/cli/commands/export.mdx b/docs/cli/commands/export.mdx index 076d6d917..b1dcb5d32 100644 --- a/docs/cli/commands/export.mdx +++ b/docs/cli/commands/export.mdx @@ -9,8 +9,7 @@ infisical export [options] ## Description -Export environment variables from the platform into a file format. -By default, secrets are saved to `.env` for dotenv formats or `secrets.{format}` for other formats in the current directory. +Export environment variables from the platform into a file format. By default, output is sent to stdout (standard output), but you can use the `--output-file` flag to save directly to a file. ## Subcommands & flags @@ -20,29 +19,21 @@ By default, secrets are saved to `.env` for dotenv formats or `secrets.{format}` ```bash $ infisical export -# Export variables to .env file (default behavior) -infisical export +# Export variables to a .env file +infisical export > .env +infisical export --output-file=./.env -# Export variables to .env file with explicit format -infisical export --format=dotenv +# Export variables to a .env file (with export keyword) +infisical export --format=dotenv-export > .env +infisical export --format=dotenv-export --output-file=./.env -# Export variables to .env file (with export keyword) -infisical export --format=dotenv-export +# Export variables to a JSON file +infisical export --format=json > secrets.json +infisical export --format=json --output-file=./secrets.json -# Export variables to secrets.csv file -infisical export --format=csv - -# Export variables to secrets.json file -infisical export --format=json - -# Export variables to secrets.yaml file -infisical export --format=yaml - -# Export to custom file path -infisical export --format=json --output-file=./config/prod-secrets.json - -# Export to directory (uses default filename) -infisical export --format=yaml --output-file=./secrets/ +# Export variables to a YAML file +infisical export --format=yaml > secrets.yaml +infisical export --format=yaml --output-file=./secrets.yaml # Render secrets using a custom template file infisical export --template= @@ -88,22 +79,26 @@ infisical export --template= ```bash # Export to specific file - infisical export --format=json --output-file=secrets.json + infisical export --format=json --output-file=./secrets.json # Export to directory (uses default filename based on format) - infisical export --format=yaml --output-file=./config/ - - # Export with full path - infisical export --format=csv --output-file=/home/user/secrets/prod.csv - - # Export with home directory expansion - infisical export --format=json --output-file=~/secrets/prod.json + infisical export --format=yaml --output-file=./ ``` - **Default behavior when not specified:** - - For `dotenv` and `dotenv-export` formats: defaults to `.env` - - For other formats: defaults to `secrets.{format}` (e.g., `secrets.json`, `secrets.csv`) - - All defaults save to the current working directory + **When `--output-file` is specified:** + - Secrets are saved directly to the specified file + - A success message is displayed showing the file path + - For directories: adds default filename `secrets.{format}` (e.g., `secrets.json`, `secrets.yaml`) + - For dotenv formats in directories: uses `.env` as the filename + + **When `--output-file` is NOT specified (default behavior):** + - Output is sent to stdout (standard output) + - You can use shell redirection like `infisical export > secrets.json` + - Maintains backwards compatibility with existing scripts + + + If you're using shell redirection and your token expires, re-authentication will fail because the prompt can't display properly due to the redirection. + @@ -128,6 +123,7 @@ infisical export --template= ``` + Used to set the environment that secrets are pulled from. @@ -196,7 +192,7 @@ infisical export --template= ```bash # Example - infisical run --tags=tag1,tag2,tag3 -- npm run dev + infisical export --tags=tag1,tag2,tag3 --env=dev ``` Note: you must reference the tag by its slug name not its fully qualified name. Go to project settings to view all tag slugs. @@ -205,4 +201,4 @@ infisical export --template= - + \ No newline at end of file