Add util method to commands file that prints an error in a specific format
MODIFY
commands/command.go
commands/command.go
package commands
import (
+ "fmt"
+ "github.com/Bios-Marcel/cordless/config"
+ "github.com/Bios-Marcel/cordless/ui/tviewutil"
"io"
"strings"
)
@@ -83,3 +86,10 @@ OUTER_LOOP:
return parameters
}
+
+// PrintError message writes an error to the given io.Writer in the
+// default format, using the correct colors and punctuation.
+func PrintError(writer io.Writer, error, reason string) {
+ errorColor := tviewutil.ColorToHex(config.GetTheme().ErrorColor)
+ fmt.Fprintf(writer, "[%s]%s:\n\t[%s]%s\n", errorColor, error, errorColor, reason)
+}

Add util method to commands file that prints an error in a specific format