Make --color and --no-color exclusive
Signed-off-by: Yusuke Kuoka <ykuoka@gmail.com>
This commit is contained in:
parent
97e0ca73ca
commit
f84ab66ba0
8
main.go
8
main.go
|
|
@ -952,6 +952,10 @@ func (c configImpl) Color() bool {
|
||||||
return c
|
return c
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if c.NoColor() {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
// We replicate the helm-diff behavior in helmfile
|
// We replicate the helm-diff behavior in helmfile
|
||||||
// because when when helmfile calls helm-diff, helm-diff has no access to term and therefore
|
// because when when helmfile calls helm-diff, helm-diff has no access to term and therefore
|
||||||
// we can't rely on helm-diff's ability to auto-detect term for color output.
|
// we can't rely on helm-diff's ability to auto-detect term for color output.
|
||||||
|
|
@ -1021,6 +1025,10 @@ func action(do func(*app.App, configImpl) error) func(*cli.Context) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if err := app.ValidateConfig(conf); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
a := app.New(conf)
|
a := app.New(conf)
|
||||||
|
|
||||||
if err := do(a, conf); err != nil {
|
if err := do(a, conf); err != nil {
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,11 @@
|
||||||
|
package app
|
||||||
|
|
||||||
|
import "errors"
|
||||||
|
|
||||||
|
func ValidateConfig(conf ApplyConfigProvider) error {
|
||||||
|
if conf.NoColor() && conf.Color() {
|
||||||
|
return errors.New("--color and --no-color cannot be specified at the same time")
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue