mirror of
https://github.com/helmfile/helmfile.git
synced 2026-10-06 00:57:50 +02:00
Make --color and --no-color exclusive
Signed-off-by: Yusuke Kuoka <ykuoka@gmail.com>
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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
|
||||
}
|
||||
Reference in New Issue
Block a user