cmd: force no color output when NO_COLOR env presents

This commit is contained in:
Vladimir Varankin
2024-11-16 11:54:19 +11:00
committed by Mike Farah
parent b8607bacb9
commit f071a25fa9
2 changed files with 13 additions and 4 deletions
+12 -3
View File
@@ -1,5 +1,7 @@
package cmd
import "os"
var unwrapScalarFlag = newUnwrapFlag()
var unwrapScalar = false
@@ -12,9 +14,6 @@ var outputFormat = ""
var inputFormat = ""
var exitStatus = false
var forceColor = false
var forceNoColor = false
var colorsEnabled = false
var indent = 2
var noDocSeparators = false
var nullInput = false
@@ -23,6 +22,16 @@ var verbose = false
var version = false
var prettyPrint = false
var forceColor = false
var forceNoColor = false
var colorsEnabled = false
func init() {
// when NO_COLOR environment variable presents and not an empty string the colored output should be disabled;
// refer to no-color.org
forceNoColor = os.Getenv("NO_COLOR") != ""
}
// can be either "" (off), "extract" or "process"
var frontMatter = ""