// AddLabelsToColumnsFlag added a user flag to print resource labels into columns. Currently used in qingctl get command func AddLabelsToColumnsFlag(cmd *cobra.Command, value *util.StringList, usage string) { flag := &pflag.Flag{ Name: "label-columns", Shorthand: "L", Usage: usage, Value: value, DefValue: value.String(), } cmd.Flags().AddFlag(flag) }
func AddJsonFilenameFlag(cmd *cobra.Command, value *util.StringList, usage string) { annotations := []string{"json", "yaml", "yml"} annotation := make(map[string][]string) annotation[cobra.BashCompFilenameExt] = annotations flag := &pflag.Flag{ Name: "filename", Shorthand: "f", Usage: usage, Value: value, DefValue: value.String(), Annotations: annotation, } cmd.Flags().AddFlag(flag) }