Skip to content

Commit

Permalink
feat: add MONOKIT_NOCOLOR variable
Browse files Browse the repository at this point in the history
  • Loading branch information
kreatoo committed Jan 17, 2025
1 parent 7a6a323 commit 4c01cae
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.

---


Expand Down
9 changes: 8 additions & 1 deletion common/colors.go
Original file line number Diff line number Diff line change
@@ -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 = ""
}
5 changes: 5 additions & 0 deletions common/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 4c01cae

Please sign in to comment.