CLI Feedback
For example,
On https://cli.github.com/manual/gh_run_list
-s, --status <string>
Filter runs by status: {queued|completed|in_progress|requested|waiting|action_required|cancelled|failure|neutral|skipped|stale|startup_failure|success|timed_out}
On https://cli.github.com/manual/gh_cache_list
-S, --sort <string>
Sort fetched caches: {created_at|last_accessed_at|size_in_bytes}
The current plain format reduces readability.
What have you loved?
A prettier format, perhaps with some rewording.
-S, --sort <string>
Sort fetched caches: one of "created_at", "last_accessed_at", "size_in_bytes"
Anything else?
The format seems controlled by
|
// StringEnumFlag defines a new string flag that only allows values listed in options. |
|
func StringEnumFlag(cmd *cobra.Command, p *string, name, shorthand, defaultValue string, options []string, usage string) *pflag.Flag { |
|
*p = defaultValue |
|
val := &enumValue{string: p, options: options} |
|
f := cmd.Flags().VarPF(val, name, shorthand, fmt.Sprintf("%s: %s", usage, formatValuesForUsageDocs(options))) |
|
_ = cmd.RegisterFlagCompletionFunc(name, func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { |
|
return options, cobra.ShellCompDirectiveNoFileComp |
|
}) |
|
return f |
|
} |
|
|
|
func StringSliceEnumFlag(cmd *cobra.Command, p *[]string, name, shorthand string, defaultValues, options []string, usage string) *pflag.Flag { |
|
*p = defaultValues |
|
val := &enumMultiValue{value: p, options: options} |
|
f := cmd.Flags().VarPF(val, name, shorthand, fmt.Sprintf("%s: %s", usage, formatValuesForUsageDocs(options))) |
|
_ = cmd.RegisterFlagCompletionFunc(name, func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { |
|
return options, cobra.ShellCompDirectiveNoFileComp |
|
}) |
|
return f |
|
} |
|
func formatValuesForUsageDocs(values []string) string { |
|
return fmt.Sprintf("{%s}", strings.Join(values, "|")) |
|
} |
Loosely related to #8348
CLI Feedback
For example,
On https://cli.github.com/manual/gh_run_list
On https://cli.github.com/manual/gh_cache_list
The current plain format reduces readability.
What have you loved?
A prettier format, perhaps with some rewording.
Anything else?
The format seems controlled by
cli/pkg/cmdutil/flags.go
Lines 27 to 46 in a74a71e
cli/pkg/cmdutil/flags.go
Lines 68 to 70 in a74a71e
Loosely related to #8348