Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New flag: no-color #52

Merged
merged 2 commits into from
Mar 17, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions cli/cmds.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ func Make() *cobra.Command {
pflags.BoolP("check", "c", false, "return an error during diff if formatting is required")
pflags.BoolP("verbose", "v", false, "show files as they are processed& additional stats")
pflags.BoolP("quiet", "q", false, "quiet mode, only shows block line numbers ")
pflags.BoolP("uncoloured", "u", false, "disable coloured output")

if err := viper.BindPFlag("fmtcompat", pflags.Lookup("fmtcompat")); err != nil {
panic(err)
Expand All @@ -240,9 +241,17 @@ func Make() *cobra.Command {
if err := viper.BindPFlag("verbose", pflags.Lookup("verbose")); err != nil {
panic(err)
}
if err := viper.BindPFlag("uncoloured", pflags.Lookup("uncoloured")); err != nil {
panic(err)
}

//todo bind to env?

cobra.OnInitialize(func() {
if viper.GetBool("uncoloured") {
c.Enable = false
}
})
return root
}

Expand Down