MCPcopy Create free account
hub / github.com/avamsi/climate / run

Method run

command.go:117–139  ·  view source on GitHub ↗
(ctx context.Context)

Source from the content-addressed store, hash-verified

115}
116
117func (cmd *command) run(ctx context.Context) error {
118 normalize := func(_ *pflag.FlagSet, name string) pflag.NormalizedName {
119 return pflag.NormalizedName(internal.NormalizeToKebabCase(name))
120 }
121 // While we prefer kebab-case for flags, we do support other well-formed,
122 // cases through normalization (but only kebab-case shows up in --help).
123 cmd.delegate.SetGlobalNormalizationFunc(normalize)
124 if v := version(); v != "" {
125 // Add the version subcommand only when the root command already has
126 // subcommands (similar to how Cobra does it for help / completion).
127 if cmd.delegate.HasSubCommands() {
128 cmd.delegate.AddCommand(versionCommand(cmd.delegate.Name(), v))
129 }
130 cmd.delegate.Version = v
131 }
132 // Align the flag usages as a table (pflag's FlagUsages already does this to
133 // some extent but doesn't align types and default values).
134 cobra.AddTemplateFunc("flagUsages", flagUsages)
135 t := cmd.delegate.UsageTemplate()
136 t = strings.ReplaceAll(t, ".FlagUsages", " | flagUsages")
137 cmd.delegate.SetUsageTemplate(t)
138 return cmd.delegate.ExecuteContext(ctx)
139}
140
141type funcCommandBuilder struct {
142 name string

Callers 2

ExecuteMethod · 0.45
ExecuteMethod · 0.45

Calls 3

NormalizeToKebabCaseFunction · 0.92
versionFunction · 0.85
versionCommandFunction · 0.85

Tested by

no test coverage detected