From 1b8e71ca1f8518e1181145cffdd97ad75c09d0e3 Mon Sep 17 00:00:00 2001 From: Megan Marsh Date: Wed, 31 Mar 2021 11:44:40 -0700 Subject: [PATCH] switch to using ui once it is initialized --- main.go | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/main.go b/main.go index aa0b51d2e..df3e830f2 100644 --- a/main.go +++ b/main.go @@ -187,7 +187,7 @@ func wrappedMain() int { // Set this so that we don't get colored output in our machine- // readable UI. if err := os.Setenv("PACKER_NO_COLOR", "1"); err != nil { - fmt.Fprintf(os.Stdout, "%s Packer failed to initialize UI: %s\n", ErrorPrefix, err) + ui.Error(fmt.Sprintf("Packer failed to initialize UI: %s\n", err)) return 1 } } else { @@ -202,13 +202,12 @@ func wrappedMain() int { currentPID := os.Getpid() backgrounded, err := checkProcess(currentPID) if err != nil { - fmt.Fprintf(os.Stdout, "%s cannot determine if process is in "+ - "background: %s\n", ErrorPrefix, err) + ui.Error(fmt.Sprintf("cannot determine if process is in background: %s\n", err)) } if backgrounded { - fmt.Fprintf(os.Stdout, "%s Running in background, not using a TTY\n", ErrorPrefix) + ui.Error("Running in background, not using a TTY\n") } else if TTY, err := openTTY(); err != nil { - fmt.Fprintf(os.Stdout, "%s No tty available: %s\n", ErrorPrefix, err) + ui.Error(fmt.Sprintf("No tty available: %s\n", err)) } else { basicUi.TTY = TTY basicUi.PB = &packer.UiProgressBar{} @@ -246,7 +245,7 @@ func wrappedMain() int { } if err != nil { - fmt.Fprintf(os.Stdout, "%s Error executing CLI: %s\n", ErrorPrefix, err) + ui.Error(fmt.Sprintf("Error executing CLI: %s\n", err)) return 1 }