Skip to content

Commit

Permalink
Don't print optional logs when redirecting file output to stdout
Browse files Browse the repository at this point in the history
  • Loading branch information
Piccirello committed Jan 28, 2020
1 parent 2c91592 commit 171332b
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions pkg/cmd/enclave_secrets.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,9 @@ Print your secrets to stdout in env format without writing to the filesystem
$ doppler enclave secrets download --format=env --no-file`,
Args: cobra.MaximumNArgs(1),
Run: func(cmd *cobra.Command, args []string) {
silent := utils.GetBoolFlag(cmd, "silent")
saveFile := !utils.GetBoolFlag(cmd, "no-file")
// don't log anything extraneous when printing secrets to stdout
silent := !saveFile || utils.GetBoolFlag(cmd, "silent")
jsonFlag := utils.OutputJSON
localConfig := configuration.LocalConfig(cmd)

Expand Down Expand Up @@ -227,10 +228,7 @@ $ doppler enclave secrets download --format=env --no-file`,
}

if !saveFile {
if !silent {
fmt.Println(string(body))
}

fmt.Println(string(body))
return
}

Expand All @@ -240,10 +238,10 @@ $ doppler enclave secrets download --format=env --no-file`,
if filePath == "" {
utils.HandleError(errors.New("invalid file path"))
}
} else if format == "json" {
filePath = filepath.Join(".", "doppler.json")
} else {
} else if format == "env" {
filePath = filepath.Join(".", "doppler.env")
} else {
filePath = filepath.Join(".", "doppler.json")
}

utils.LogDebug("Encrypting Enclave secrets")
Expand Down

0 comments on commit 171332b

Please sign in to comment.