From cd941153c6201ae406ec5258cc065a607f3c4556 Mon Sep 17 00:00:00 2001 From: John O'Keefe Date: Fri, 8 Dec 2023 19:05:29 -0500 Subject: [PATCH] fixed accessability colors and cleaned comments --- error.go | 9 +++++++-- main.go | 13 ++++--------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/error.go b/error.go index a54a5fa..5d1320b 100644 --- a/error.go +++ b/error.go @@ -1,10 +1,15 @@ package main -import "log" +import ( + "os" + + "github.com/pterm/pterm" +) func Error(err error) { if err != nil { - log.Fatal(err) + pterm.Error.Println(err) + os.Exit(1) } return } diff --git a/main.go b/main.go index 7822592..99d3635 100644 --- a/main.go +++ b/main.go @@ -11,12 +11,12 @@ import ( ) func main() { - pterm.DefaultHeader.Println("Welcome to Checkdigit Calculator") + pterm.DefaultHeader.WithBackgroundStyle(pterm.NewStyle(pterm.BgCyan)).WithTextStyle(pterm.NewStyle(pterm.FgCyan)).Println("Welcome to Checkdigit Calculator") directory, err := os.Getwd() Error(err) - pterm.DefaultBasicText.Printf("What is the name of the file in this directory?: ") + pterm.Printf(pterm.Cyan("What is the name of the file in this directory?: ")) reader := bufio.NewReader(os.Stdin) input, err := reader.ReadString('\n') Error(err) @@ -35,8 +35,6 @@ func main() { fmt.Println(scanner.Err()) } - // upcProgressbar, err := pterm.DefaultProgressbar.WithTotal(len(upcs)).WithTitle("Processing UPCs").Start() - pterm.DefaultSpinner.Start() Error(err) @@ -108,11 +106,8 @@ func main() { remainderString := strconv.Itoa(remainder) gtins = append(gtins, upc+remainderString) - // upcProgressbar.Increment() } - // answerProgressbar, err := pterm.DefaultProgressbar.WithTotal(len(gtins)).WithTitle("Processing UPCs").Start() - if _, err := os.Stat(directory + "/answer.txt"); err == nil { e := os.Remove(directory + "/answer.txt") Error(e) @@ -126,10 +121,10 @@ func main() { for _, gtin := range gtins { _, err := answerFile.WriteString(gtin + "\n") Error(err) - // answerProgressbar.Increment() } pterm.DefaultSpinner.Stop() - pterm.DefaultBasicText.Println("The answer.txt file has been successfully generated with check digits.") + pterm.Println("\n") + pterm.Success.Println("The answer.txt file has been successfully generated with check digits.") }