MCPcopy
hub / github.com/helm/helm / bindOutputFlag

Function bindOutputFlag

pkg/cmd/flags.go:121–139  ·  view source on GitHub ↗

bindOutputFlag will add the output flag to the given command and bind the value to the given format pointer

(cmd *cobra.Command, varRef *output.Format)

Source from the content-addressed store, hash-verified

119// bindOutputFlag will add the output flag to the given command and bind the
120// value to the given format pointer
121func bindOutputFlag(cmd *cobra.Command, varRef *output.Format) {
122 cmd.Flags().VarP(newOutputValue(output.Table, varRef), outputFlag, "o",
123 "prints the output in the specified format. Allowed values: "+strings.Join(output.Formats(), ", "))
124
125 err := cmd.RegisterFlagCompletionFunc(outputFlag, func(_ *cobra.Command, _ []string, _ string) ([]string, cobra.ShellCompDirective) {
126 var formatNames []string
127 for format, desc := range output.FormatsWithDesc() {
128 formatNames = append(formatNames, fmt.Sprintf("%s\t%s", format, desc))
129 }
130
131 // Sort the results to get a deterministic order for the tests
132 sort.Strings(formatNames)
133 return formatNames, cobra.ShellCompDirectiveNoFileComp
134 })
135
136 if err != nil {
137 log.Fatal(err)
138 }
139}
140
141type outputValue output.Format
142

Callers 10

newSearchHubCmdFunction · 0.85
newStatusCmdFunction · 0.85
newRepoListCmdFunction · 0.85
newGetMetadataCmdFunction · 0.85
newInstallCmdFunction · 0.85
newSearchRepoCmdFunction · 0.85
newUpgradeCmdFunction · 0.85
newHistoryCmdFunction · 0.85
newGetValuesCmdFunction · 0.85
newListCmdFunction · 0.85

Calls 4

FormatsFunction · 0.92
FormatsWithDescFunction · 0.92
newOutputValueFunction · 0.85
FatalMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…