Skip to content
Myr

Add merging of CommandLine flags to Root command

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Albert Nigmatzianov · committed by Albert Nigmatzianov · parent 37a4355 · Browse files · 2 files+10 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+10 added−0 removed

  • other:+10 added−0 removed

2 files+10 added−0 removed

modified:cobra_test.go+8 added
1145 unmodified lines
1146 t.Error("cmdPrint and cmdEchoSub should had the normalization function of rootCmd")1147 }1148}11491150func TestFlagOnPflagCommandLine(t *testing.T) {1151 flagName := "flagOnCommandLine"1152 pflag.CommandLine.String(flagName, "", "about my flag")1153 r := fullSetupTest("--help")11541155 checkResultContains(t, r, flagName)1156}11571158func TestAddTemplateFunctions(t *testing.T) {1159 AddTemplateFunc("t", func() bool { return true })1160 AddTemplateFuncs(template.FuncMap{1161 "f": func() bool { return false },
43 unmodified lines
modified:command.go+2 added
1256 unmodified lines
1257 c.parentsPflags.SetOutput(c.OutOrStderr())1258 c.parentsPflags.SortFlags = false1259 }12601261 c.Root().PersistentFlags().AddFlagSet(flag.CommandLine)12621263 c.VisitParents(func(x *Command) {1264 if x.HasPersistentFlags() {1265 x.PersistentFlags().VisitAll(func(f *flag.Flag) {1266 if c.parentsPflags.Lookup(f.Name) == nil {
9 unmodified lines