Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

feat: adding new export format

Michel Wilhelm799a83994015
diff --git a/cli/packages/cmd/export.go b/cli/packages/cmd/export.go
index fd04e9ce2c..33021f1c1c 100644
--- a/cli/packages/cmd/export.go
+++ b/cli/packages/cmd/export.go
@@ -16,10 +16,11 @@ import (
)
const (
- FormatDotenv string = "dotenv"
- FormatJson string = "json"
- FormatCSV string = "csv"
- FormatYaml string = "yaml"
+ FormatDotenv string = "dotenv"
+ FormatJson string = "json"
+ FormatCSV string = "csv"
+ FormatYaml string = "yaml"
+ FormatDotEnvExport string = "dotenv-export"
)
// exportCmd represents the export command
@@ -85,6 +86,8 @@ func formatEnvs(envs []models.SingleEnvironmentVariable, format string) (string,
switch strings.ToLower(format) {
case FormatDotenv:
return formatAsDotEnv(envs), nil
+ case FormatDotEnvExport:
+ return formatAsDotEnvExport(envs), nil
case FormatJson:
return formatAsJson(envs), nil
case FormatCSV:
@@ -117,6 +120,15 @@ func formatAsDotEnv(envs []models.SingleEnvironmentVariable) string {
return dotenv
}
+// Format environment variables as a dotenv file with export at the beginning
+func formatAsDotEnvExport(envs []models.SingleEnvironmentVariable) string {
+ var dotenv string
+ for _, env := range envs {
+ dotenv += fmt.Sprintf("export %s='%s'\n", env.Key, env.Value)
+ }
+ return dotenv
+}
+
func formatAsYaml(envs []models.SingleEnvironmentVariable) string {
var dotenv string
for _, env := range envs {