diff --git a/README.md b/README.md index 89eb289..b859d61 100644 --- a/README.md +++ b/README.md @@ -139,6 +139,8 @@ Replace NAME with the name of the tool you want to run (e.g. `osHealth`). A log file will be put on `/var/log/monokit.log` if you want to check the errors. They will also be printed to stdout. +If you use Monokit on a place where there is no proper color support, you can disable the color output by setting the `MONOKIT_NOCOLOR`  environment variable to `true` or `1`. + --- diff --git a/common/colors.go b/common/colors.go index b53ea30..45b71be 100644 --- a/common/colors.go +++ b/common/colors.go @@ -1,8 +1,15 @@ package common -const ( +var ( Reset = "\033[0m" Blue = "\033[94m" Green = "\033[92m" Fail = "\033[91m" ) + +func RemoveColors() { + Reset = "" + Blue = "" + Green = "" + Fail = "" +} diff --git a/common/main.go b/common/main.go index 603f6f2..626a572 100644 --- a/common/main.go +++ b/common/main.go @@ -95,6 +95,11 @@ func Init() { // Create lockfile os.Create(TmpDir + "/monokit.lock") + + // Check if env variable MONOKIT_NOCOLOR is set to true + if os.Getenv("MONOKIT_NOCOLOR") == "true" || os.Getenv("MONOKIT_NOCOLOR") == "1" { + RemoveColors() + } LogInit(userMode) ConfInit("global", &Config)