Make --color and --no-color exclusive

Signed-off-by: Yusuke Kuoka <ykuoka@gmail.com>
This commit is contained in:
Yusuke Kuoka 2022-04-13 23:43:12 +00:00
parent 97e0ca73ca
commit f84ab66ba0
2 changed files with 19 additions and 0 deletions

View File

@ -952,6 +952,10 @@ func (c configImpl) Color() bool {
return c
}
if c.NoColor() {
return false
}
// We replicate the helm-diff behavior in helmfile
// 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.
@ -1021,6 +1025,10 @@ func action(do func(*app.App, configImpl) error) func(*cli.Context) error {
return err
}
if err := app.ValidateConfig(conf); err != nil {
return err
}
a := app.New(conf)
if err := do(a, conf); err != nil {

View File

@ -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
}