diff --git a/cmd/root_test.go b/cmd/root_test.go index abc3a7e8..9536e569 100644 --- a/cmd/root_test.go +++ b/cmd/root_test.go @@ -380,3 +380,30 @@ func Test_flag_config_TF(t *testing.T) { // both configs set to true, comments should be output require.Contains(t, string(b), `commented at`) } + +// flag (explicitly) unset, config true == no comments +func Test_flag_config_FT(t *testing.T) { + repo := copyTestRepo(t) + + err := setConfigValues(repo, "true", "true") + if err != nil { + t.Skip(err) + } + os.Remove(repo + "/lab.toml") + + cmd := exec.Command(labBinaryPath, "mr", "show", "1", "--comments=false") + cmd.Dir = repo + + b, err := cmd.CombinedOutput() + if err != nil { + t.Log(string(b)) + t.Error(err) + } + + out := string(b) + out = stripansi.Strip(out) + + os.Remove("/home/travis/.config/lab/lab.toml") + // configs overridden on the command line, comments should not be output + require.NotContains(t, string(b), `commented at`) +} diff --git a/cmd/util.go b/cmd/util.go index 96ed7dd8..fcb0031b 100644 --- a/cmd/util.go +++ b/cmd/util.go @@ -56,7 +56,7 @@ func flagConfig(fs *flag.FlagSet) { } // if set, always use the command line option (flag) value - if f.Value.String() != f.DefValue { + if f.Changed { return } // o/w use the value in the configfile