@@ -3,7 +3,6 @@ package cmd
33import (
44 "fmt"
55 "os"
6- "strings"
76
87 "github.com/opentdf/otdfctl/pkg/cli"
98 "github.com/opentdf/otdfctl/pkg/man"
@@ -32,35 +31,20 @@ func dev_tdfDecryptCmd(cmd *cobra.Command, args []string) {
3231 cli .ExitWithError ("Failed to decrypt file" , err )
3332 }
3433
35- if output == "stdout " {
34+ if output == "" {
3635 // Print decrypted content to stdout
3736 fmt .Print (decrypted .String ())
3837 return
39- } else if output != "" {
40- // Here 'output' is the filename given with -o
41- f , err := os .Create (output )
42- if err != nil {
43- cli .ExitWithError ("Failed to write decrypted data to file" , err )
44- }
45- defer f .Close ()
46- _ , err = f .Write (decrypted .Bytes ())
47- if err != nil {
48- cli .ExitWithError ("Failed to write decrypted data to file" , err )
49- }
50- return
51- } else {
52- // Here the 'output' filename is based on the input filename
53- // Write decrypted string to file with stripped .tdf extension
54- f , err := os .Create (strings .Replace (tdfFile , ".tdf" , "" , 1 ))
55- if err != nil {
56- cli .ExitWithError ("Failed to write decrypted data to file" , err )
57- }
58- defer f .Close ()
59- _ , err = f .Write (decrypted .Bytes ())
60- if err != nil {
61- cli .ExitWithError ("Failed to write decrypted data to file" , err )
62- }
63- return
38+ }
39+ // Here 'output' is the filename given with -o
40+ f , err := os .Create (output )
41+ if err != nil {
42+ cli .ExitWithError ("Failed to write decrypted data to file" , err )
43+ }
44+ defer f .Close ()
45+ _ , err = f .Write (decrypted .Bytes ())
46+ if err != nil {
47+ cli .ExitWithError ("Failed to write decrypted data to file" , err )
6448 }
6549}
6650
0 commit comments