From 857062189c484007d9843fe3567591d0dc9e6f02 Mon Sep 17 00:00:00 2001 From: Anton Novojilov Date: Mon, 15 Nov 2021 15:37:30 +0300 Subject: [PATCH] Fix bug with printing error and warning messages with fmt verbs --- cli/cli.go | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/cli/cli.go b/cli/cli.go index 9a0205a8..cb747f96 100644 --- a/cli/cli.go +++ b/cli/cli.go @@ -37,7 +37,7 @@ import ( // Application info const ( APP = "bibop" - VER = "4.8.0" + VER = "4.8.1" DESC = "Utility for testing command-line tools" ) @@ -312,12 +312,20 @@ func getRenderer() render.Renderer { // printError prints error message to console func printError(f string, a ...interface{}) { - fmtc.Fprintf(os.Stderr, "{r}"+f+"{!}\n", a...) + if len(a) == 0 { + fmtc.Fprintln(os.Stderr, "{r}"+f+"{!}") + } else { + fmtc.Fprintf(os.Stderr, "{r}"+f+"{!}\n", a...) + } } // printError prints warning message to console func printWarn(f string, a ...interface{}) { - fmtc.Fprintf(os.Stderr, "{y}"+f+"{!}\n", a...) + if len(a) == 0 { + fmtc.Fprintln(os.Stderr, "{y}"+f+"{!}") + } else { + fmtc.Fprintf(os.Stderr, "{y}"+f+"{!}\n", a...) + } } // printErrorAndExit print error mesage and exit with exit code 1