MCPcopy Create free account
hub / github.com/basecamp/hey-cli / parentScopedFlags

Function parentScopedFlags

internal/cmd/help.go:256–267  ·  view source on GitHub ↗

parentScopedFlags returns inherited flags that originate from a non-root parent command. These are promoted into the FLAGS section so they're immediately visible on leaf commands.

(cmd *cobra.Command)

Source from the content-addressed store, hash-verified

254// parent command. These are promoted into the FLAGS section so they're
255// immediately visible on leaf commands.
256func parentScopedFlags(cmd *cobra.Command) *pflag.FlagSet {
257 root := cmd.Root()
258 ps := pflag.NewFlagSet("parent-scoped", pflag.ContinueOnError)
259 cmd.InheritedFlags().VisitAll(func(f *pflag.Flag) {
260 rootFlag := root.PersistentFlags().Lookup(f.Name)
261 if rootFlag != nil && rootFlag == f {
262 return // root-level — stays in INHERITED FLAGS
263 }
264 ps.AddFlag(f)
265 })
266 return ps
267}
268
269// filterInheritedFlags returns formatted flag usages for INHERITED FLAGS,
270// containing only the curated subset of root-level globals.

Callers 1

renderCommandHelpFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected