Cleaup the output (removed the colors) for windows.
diff --git a/Makefile b/Makefile
index a8e3cc6..abe0795 100644
--- a/Makefile
+++ b/Makefile
@@ -28,8 +28,8 @@
build-all:
gox -verbose \
-ldflags "-X main.version=${VERSION}" \
- -os="linux darwin " \
- -arch="amd64" \
+ -os="linux darwin windows " \
+ -arch="amd64 386" \
-output="dist/{{.OS}}-{{.Arch}}/{{.Dir}}" .
dist: build-all
diff --git a/cmd/msg.go b/cmd/msg.go
new file mode 100644
index 0000000..c122dc5
--- /dev/null
+++ b/cmd/msg.go
@@ -0,0 +1,77 @@
+// +build !windows
+
+package cmd
+
+import (
+ "fmt"
+ "os"
+)
+
+// These contanstants map to color codes for shell scripts making them
+// human readable.
+const (
+ Blue = "0;34"
+ Red = "0;31"
+ Green = "0;32"
+ Yellow = "0;33"
+ Cyan = "0;36"
+ Pink = "1;35"
+)
+
+// Color returns a string in a certain color. The first argument is a string
+// containing the color code or a constant from the table above mapped to a code.
+//
+// The following will print the string "Foo" in yellow:
+// fmt.Print(Color(Yellow, "Foo"))
+func Color(code, msg string) string {
+ return fmt.Sprintf("\033[%sm%s\033[m", code, msg)
+}
+
+// Info logs information
+func Info(msg string, args ...interface{}) {
+ if Quiet {
+ return
+ }
+ fmt.Print(Color(Green, "[INFO] "))
+ Msg(msg, args...)
+}
+
+// Debug logs debug information
+func Debug(msg string, args ...interface{}) {
+ if Quiet {
+ return
+ }
+ fmt.Print("[DEBUG] ")
+ Msg(msg, args...)
+}
+
+// Warn logs a warning
+func Warn(msg string, args ...interface{}) {
+ fmt.Fprint(os.Stderr, Color(Yellow, "[WARN] "))
+ ErrMsg(msg, args...)
+}
+
+// Error logs and error.
+func Error(msg string, args ...interface{}) {
+ fmt.Fprint(os.Stderr, Color(Red, "[ERROR] "))
+ ErrMsg(msg, args...)
+}
+
+// ErrMsg sends a message to Stderr
+func ErrMsg(msg string, args ...interface{}) {
+ if len(args) == 0 {
+ fmt.Fprint(os.Stderr, msg)
+ return
+ }
+ fmt.Fprintf(os.Stderr, msg, args...)
+}
+
+// Msg prints a message with optional arguments, that can be printed, of
+// varying types.
+func Msg(msg string, args ...interface{}) {
+ if len(args) == 0 {
+ fmt.Print(msg)
+ return
+ }
+ fmt.Printf(msg, args...)
+}
diff --git a/cmd/msg_windows.go b/cmd/msg_windows.go
new file mode 100644
index 0000000..2a4a86a
--- /dev/null
+++ b/cmd/msg_windows.go
@@ -0,0 +1,57 @@
+// +build windows
+
+package cmd
+
+import (
+ "fmt"
+ "os"
+)
+
+// Info logs information
+func Info(msg string, args ...interface{}) {
+ if Quiet {
+ return
+ }
+ fmt.Print("[INFO] ")
+ Msg(msg, args...)
+}
+
+// Debug logs debug information
+func Debug(msg string, args ...interface{}) {
+ if Quiet {
+ return
+ }
+ fmt.Print("[DEBUG] ")
+ Msg(msg, args...)
+}
+
+// Warn logs a warning
+func Warn(msg string, args ...interface{}) {
+ fmt.Fprint(os.Stderr, "[WARN] ")
+ ErrMsg(msg, args...)
+}
+
+// Error logs and error.
+func Error(msg string, args ...interface{}) {
+ fmt.Fprint(os.Stderr, "[ERROR] ")
+ ErrMsg(msg, args...)
+}
+
+// ErrMsg sends a message to Stderr
+func ErrMsg(msg string, args ...interface{}) {
+ if len(args) == 0 {
+ fmt.Fprint(os.Stderr, msg)
+ return
+ }
+ fmt.Fprintf(os.Stderr, msg, args...)
+}
+
+// Msg prints a message with optional arguments, that can be printed, of
+// varying types.
+func Msg(msg string, args ...interface{}) {
+ if len(args) == 0 {
+ fmt.Print(msg)
+ return
+ }
+ fmt.Printf(msg, args...)
+}
diff --git a/cmd/util.go b/cmd/util.go
index 8e8b1e3..1c030d7 100644
--- a/cmd/util.go
+++ b/cmd/util.go
@@ -13,26 +13,6 @@
// Quiet, when set to true, can suppress Info and Debug messages.
var Quiet = false
-// These contanstants map to color codes for shell scripts making them
-// human readable.
-const (
- Blue = "0;34"
- Red = "0;31"
- Green = "0;32"
- Yellow = "0;33"
- Cyan = "0;36"
- Pink = "1;35"
-)
-
-// Color returns a string in a certain color. The first argument is a string
-// containing the color code or a constant from the table above mapped to a code.
-//
-// The following will print the string "Foo" in yellow:
-// fmt.Print(Color(Yellow, "Foo"))
-func Color(code, msg string) string {
- return fmt.Sprintf("\033[%sm%s\033[m", code, msg)
-}
-
// BeQuiet supresses Info and Debug messages.
func BeQuiet(c cookoo.Context, p *cookoo.Params) (interface{}, cookoo.Interrupt) {
Quiet = p.Get("quiet", false).(bool)
@@ -97,52 +77,3 @@
return true, nil
}
-
-// Info logs information
-func Info(msg string, args ...interface{}) {
- if Quiet {
- return
- }
- fmt.Print(Color(Green, "[INFO] "))
- Msg(msg, args...)
-}
-
-// Debug logs debug information
-func Debug(msg string, args ...interface{}) {
- if Quiet {
- return
- }
- fmt.Print("[DEBUG] ")
- Msg(msg, args...)
-}
-
-// Warn logs a warning
-func Warn(msg string, args ...interface{}) {
- fmt.Fprint(os.Stderr, Color(Yellow, "[WARN] "))
- ErrMsg(msg, args...)
-}
-
-// Error logs and error.
-func Error(msg string, args ...interface{}) {
- fmt.Fprint(os.Stderr, Color(Red, "[ERROR] "))
- ErrMsg(msg, args...)
-}
-
-// ErrMsg sends a message to Stderr
-func ErrMsg(msg string, args ...interface{}) {
- if len(args) == 0 {
- fmt.Fprint(os.Stderr, msg)
- return
- }
- fmt.Fprintf(os.Stderr, msg, args...)
-}
-
-// Msg prints a message with optional arguments, that can be printed, of
-// varying types.
-func Msg(msg string, args ...interface{}) {
- if len(args) == 0 {
- fmt.Print(msg)
- return
- }
- fmt.Printf(msg, args...)
-}