Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Enum values listed in option docs are poorly formatted #8349

Copy link
Copy link

Description

@muzimuzhi
Issue body actions

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

cli/pkg/cmdutil/flags.go

Lines 27 to 46 in a74a71e

// 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
}

cli/pkg/cmdutil/flags.go

Lines 68 to 70 in a74a71e

func formatValuesForUsageDocs(values []string) string {
return fmt.Sprintf("{%s}", strings.Join(values, "|"))
}

Loosely related to #8348

Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    cli.github.comRelated to GitHub CLI websiteRelated to GitHub CLI websitecoreThis issue is not accepting PRs from outside contributorsThis issue is not accepting PRs from outside contributorsdocsenhancementa request to improve CLIa request to improve CLI

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    Morty Proxy This is a proxified and sanitized view of the page, visit original site.