From 286ba5e8dc628fd68b332736c4dfeb7c109c84f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mislav=20Marohni=C4=87?= Date: Fri, 18 Feb 2022 17:32:44 +0100 Subject: [PATCH] issue/pr list: clarify search syntax --- pkg/cmd/issue/list/list.go | 21 +++++++++++++-------- pkg/cmd/pr/list/list.go | 23 +++++++++++++---------- 2 files changed, 26 insertions(+), 18 deletions(-) diff --git a/pkg/cmd/issue/list/list.go b/pkg/cmd/issue/list/list.go index da9447a54..f589c1ffb 100644 --- a/pkg/cmd/issue/list/list.go +++ b/pkg/cmd/issue/list/list.go @@ -57,12 +57,17 @@ func NewCmdList(f *cmdutil.Factory, runF func(*ListOptions) error) *cobra.Comman cmd := &cobra.Command{ Use: "list", - Short: "List and filter issues in this repository", + Short: "List issues in a repository", + Long: heredoc.Doc(` + List issues in a GitHub repository. + + The search query syntax is documented here: + + `), Example: heredoc.Doc(` - $ gh issue list -l "bug" -l "help wanted" - $ gh issue list -A monalisa - $ gh issue list -a "@me" - $ gh issue list --web + $ gh issue list --label "bug" --label "help wanted" + $ gh issue list --author monalisa + $ gh issue list --assignee "@me" $ gh issue list --milestone "The big 1.0" $ gh issue list --search "error no:assignee sort:created-asc" `), @@ -83,9 +88,9 @@ func NewCmdList(f *cmdutil.Factory, runF func(*ListOptions) error) *cobra.Comman }, } - cmd.Flags().BoolVarP(&opts.WebMode, "web", "w", false, "Open the browser to list the issue(s)") + cmd.Flags().BoolVarP(&opts.WebMode, "web", "w", false, "List issues in the web browser") cmd.Flags().StringVarP(&opts.Assignee, "assignee", "a", "", "Filter by assignee") - cmd.Flags().StringSliceVarP(&opts.Labels, "label", "l", nil, "Filter by labels") + cmd.Flags().StringSliceVarP(&opts.Labels, "label", "l", nil, "Filter by label") cmd.Flags().StringVarP(&opts.State, "state", "s", "open", "Filter by state: {open|closed|all}") _ = cmd.RegisterFlagCompletionFunc("state", func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { return []string{"open", "closed", "all"}, cobra.ShellCompDirectiveNoFileComp @@ -93,7 +98,7 @@ func NewCmdList(f *cmdutil.Factory, runF func(*ListOptions) error) *cobra.Comman cmd.Flags().IntVarP(&opts.LimitResults, "limit", "L", 30, "Maximum number of issues to fetch") cmd.Flags().StringVarP(&opts.Author, "author", "A", "", "Filter by author") cmd.Flags().StringVar(&opts.Mention, "mention", "", "Filter by mention") - cmd.Flags().StringVarP(&opts.Milestone, "milestone", "m", "", "Filter by milestone `number` or `title`") + cmd.Flags().StringVarP(&opts.Milestone, "milestone", "m", "", "Filter by milestone number or title") cmd.Flags().StringVarP(&opts.Search, "search", "S", "", "Search issues with `query`") cmdutil.AddJSONFlags(cmd, &opts.Exporter, api.IssueFields) diff --git a/pkg/cmd/pr/list/list.go b/pkg/cmd/pr/list/list.go index 01e71b948..9238f03d6 100644 --- a/pkg/cmd/pr/list/list.go +++ b/pkg/cmd/pr/list/list.go @@ -53,22 +53,25 @@ func NewCmdList(f *cmdutil.Factory, runF func(*ListOptions) error) *cobra.Comman cmd := &cobra.Command{ Use: "list", - Short: "List and filter pull requests in this repository", + Short: "List pull requests in a repository", + Long: heredoc.Doc(` + List pull requests in a GitHub repository. + + The search query syntax is documented here: + + `), Example: heredoc.Doc(` List PRs authored by you $ gh pr list --author "@me" - List PRs assigned to you - $ gh pr list --assignee "@me" - - List PRs by label, combining multiple labels with AND + List only PRs with all of the given labels $ gh pr list --label bug --label "priority 1" - List PRs using search syntax + Filter PRs using search syntax $ gh pr list --search "status:success review:required" - Open the list of PRs in a web browser - $ gh pr list --web + Find a PR that introduced a given commit + $ gh pr list --search "" --state merged `), Aliases: []string{"ls"}, Args: cmdutil.NoArgsQuoteReminder, @@ -99,7 +102,7 @@ func NewCmdList(f *cmdutil.Factory, runF func(*ListOptions) error) *cobra.Comman }, } - cmd.Flags().BoolVarP(&opts.WebMode, "web", "w", false, "Open the browser to list the pull requests") + cmd.Flags().BoolVarP(&opts.WebMode, "web", "w", false, "List pull requests in the web browser") cmd.Flags().IntVarP(&opts.LimitResults, "limit", "L", 30, "Maximum number of items to fetch") cmd.Flags().StringVarP(&opts.State, "state", "s", "open", "Filter by state: {open|closed|merged|all}") _ = cmd.RegisterFlagCompletionFunc("state", func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { @@ -107,7 +110,7 @@ func NewCmdList(f *cmdutil.Factory, runF func(*ListOptions) error) *cobra.Comman }) cmd.Flags().StringVarP(&opts.BaseBranch, "base", "B", "", "Filter by base branch") cmd.Flags().StringVarP(&opts.HeadBranch, "head", "H", "", "Filter by head branch") - cmd.Flags().StringSliceVarP(&opts.Labels, "label", "l", nil, "Filter by labels") + cmd.Flags().StringSliceVarP(&opts.Labels, "label", "l", nil, "Filter by label") cmd.Flags().StringVarP(&opts.Author, "author", "A", "", "Filter by author") cmd.Flags().StringVar(&opts.AppAuthor, "app", "", "Filter by GitHub App author") cmd.Flags().StringVarP(&opts.Assignee, "assignee", "a", "", "Filter by assignee")