Skip to content

Commit

Permalink
use logger error string
Browse files Browse the repository at this point in the history
  • Loading branch information
steviebps committed Feb 25, 2021
1 parent 9256405 commit c46cb18
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions cmd/print.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@ import (
"os"

"github.com/spf13/cobra"
"github.com/steviebps/rein/internal/logger"
"github.com/steviebps/rein/utils"
)

var printCmdError = logger.ErrorWithPrefix("Error running print command: ")

// printCmd represents the print command
var printCmd = &cobra.Command{
Use: "print",
Expand All @@ -17,10 +20,17 @@ var printCmd = &cobra.Command{
output, _ := cmd.Flags().GetString("output")

if output != "" {
utils.WriteChamberToFile(output, globalChamber, pretty)
if err := utils.WriteChamberToFile(output, globalChamber, pretty); err != nil {
printCmdError(err.Error())
os.Exit(1)
}
} else {
globalChamber.EncodeWith(cmd.OutOrStdout(), pretty)
if err := globalChamber.EncodeWith(cmd.OutOrStdout(), pretty); err != nil {
printCmdError(err.Error())
os.Exit(1)
}
}

os.Exit(0)
},
}
Expand Down

0 comments on commit c46cb18

Please sign in to comment.