diff --git a/pkg/cmd/root/help_topic.go b/pkg/cmd/root/help_topic.go index 322bc4f77..a375d9e20 100644 --- a/pkg/cmd/root/help_topic.go +++ b/pkg/cmd/root/help_topic.go @@ -304,35 +304,6 @@ var HelpTopics = []helpTopic{ control some behavior. `), }, - { - name: "search-syntax", - short: "Search syntax for gh commands", - long: heredoc.Docf(` - Excluding search results that match a qualifier - - In a browser, the GitHub search syntax supports excluding results that match a search qualifier - by prefixing the qualifier with a hyphen. For example, to search for issues that - do not have the label "bug", you would use %[1]s-label:bug%[1]s as a search qualifier. - - %[1]sgh%[1]s supports this syntax in %[1]sgh search%[1]s as well, but it requires extra - syntax to avoid the hyphen being interpreted as a command line flag because it begins with a hyphen. - - On Unix-like systems, you can use the %[1]s--%[1]s argument to indicate that - the arguments that follow are not a flag, but rather a query string. For example: - - $ gh search issues -- "my-search-query -label:bug" - - On PowerShell, you must use both the %[1]s--%[2]s%[1]s argument and the %[1]s--%[1]s argument to - produce the same effect. For example: - - $ gh --%[2]s search issues -- "my search query -label:bug" - - See the following for more information: - - GitHub search syntax: - - The PowerShell stop parse flag %[1]s--%[2]s%[1]s: - - The Unix-like %[1]s--%[1]s argument: - `, "`", "%"), - }, } func NewCmdHelpTopic(ios *iostreams.IOStreams, ht helpTopic) *cobra.Command { diff --git a/pkg/cmd/search/code/code.go b/pkg/cmd/search/code/code.go index 5e80c1017..7ef2a4193 100644 --- a/pkg/cmd/search/code/code.go +++ b/pkg/cmd/search/code/code.go @@ -47,7 +47,7 @@ func NewCmdCode(f *cmdutil.Factory, runF func(*CodeOptions) error) *cobra.Comman The results might not match what is seen on %[1]sgithub.com%[1]s, and new features like regex search are not yet available via the GitHub API. - For more information on handling search queries containing a hyphen, run %[1]sgh help search-syntax%[1]s. + For more information on handling search queries containing a hyphen, run %[1]sgh search --help%[1]s. `, "`"), Example: heredoc.Doc(` # Search code matching "react" and "lifecycle" diff --git a/pkg/cmd/search/commits/commits.go b/pkg/cmd/search/commits/commits.go index ed5d1f758..939109b65 100644 --- a/pkg/cmd/search/commits/commits.go +++ b/pkg/cmd/search/commits/commits.go @@ -46,7 +46,7 @@ func NewCmdCommits(f *cmdutil.Factory, runF func(*CommitsOptions) error) *cobra. GitHub search syntax is documented at: - For more information on handling search queries containing a hyphen, run %[1]sgh help search-syntax%[1]s. + For more information on handling search queries containing a hyphen, run %[1]sgh search --help%[1]s. `, "`"), Example: heredoc.Doc(` # Search commits matching set of keywords "readme" and "typo" diff --git a/pkg/cmd/search/issues/issues.go b/pkg/cmd/search/issues/issues.go index 0edca4b31..1d6ec6428 100644 --- a/pkg/cmd/search/issues/issues.go +++ b/pkg/cmd/search/issues/issues.go @@ -35,7 +35,7 @@ func NewCmdIssues(f *cmdutil.Factory, runF func(*shared.IssuesOptions) error) *c GitHub search syntax is documented at: - For more information on handling search queries containing a hyphen, run %[1]sgh help search-syntax%[1]s. + For more information on handling search queries containing a hyphen, run %[1]sgh search --help%[1]s. `, "`"), Example: heredoc.Doc(` # Search issues matching set of keywords "readme" and "typo" diff --git a/pkg/cmd/search/prs/prs.go b/pkg/cmd/search/prs/prs.go index 39203f5fb..98ab730b5 100644 --- a/pkg/cmd/search/prs/prs.go +++ b/pkg/cmd/search/prs/prs.go @@ -37,7 +37,7 @@ func NewCmdPrs(f *cmdutil.Factory, runF func(*shared.IssuesOptions) error) *cobr GitHub search syntax is documented at: - For more information on handling search queries containing a hyphen, run %[1]sgh help search-syntax%[1]s. + For more information on handling search queries containing a hyphen, run %[1]sgh search --help%[1]s. `, "`"), Example: heredoc.Doc(` # Search pull requests matching set of keywords "fix" and "bug" diff --git a/pkg/cmd/search/repos/repos.go b/pkg/cmd/search/repos/repos.go index a7116dd58..0a4275a87 100644 --- a/pkg/cmd/search/repos/repos.go +++ b/pkg/cmd/search/repos/repos.go @@ -47,7 +47,7 @@ func NewCmdRepos(f *cmdutil.Factory, runF func(*ReposOptions) error) *cobra.Comm GitHub search syntax is documented at: - For more information on handling search queries containing a hyphen, run %[1]sgh help search-syntax%[1]s. + For more information on handling search queries containing a hyphen, run %[1]sgh search --help%[1]s. `, "`"), Example: heredoc.Doc(` # Search repositories matching set of keywords "cli" and "shell" diff --git a/pkg/cmd/search/search.go b/pkg/cmd/search/search.go index e8714065b..e79e1ec4c 100644 --- a/pkg/cmd/search/search.go +++ b/pkg/cmd/search/search.go @@ -3,6 +3,7 @@ package search import ( "github.com/cli/cli/v2/pkg/cmdutil" "github.com/spf13/cobra" + "github.com/MakeNowJust/heredoc" searchCodeCmd "github.com/cli/cli/v2/pkg/cmd/search/code" searchCommitsCmd "github.com/cli/cli/v2/pkg/cmd/search/commits" @@ -15,7 +16,33 @@ func NewCmdSearch(f *cmdutil.Factory) *cobra.Command { cmd := &cobra.Command{ Use: "search ", Short: "Search for repositories, issues, and pull requests", - Long: "Search across all of GitHub.", + Long: heredoc.Docf(` + Search across all of GitHub. + + Excluding search results that match a qualifier + + In a browser, the GitHub search syntax supports excluding results that match a search qualifier + by prefixing the qualifier with a hyphen. For example, to search for issues that + do not have the label "bug", you would use %[1]s-label:bug%[1]s as a search qualifier. + + %[1]sgh%[1]s supports this syntax in %[1]sgh search%[1]s as well, but it requires extra + syntax to avoid the hyphen being interpreted as a command line flag because it begins with a hyphen. + + On Unix-like systems, you can use the %[1]s--%[1]s argument to indicate that + the arguments that follow are not a flag, but rather a query string. For example: + + $ gh search issues -- "my-search-query -label:bug" + + On PowerShell, you must use both the %[1]s--%[2]s%[1]s argument and the %[1]s--%[1]s argument to + produce the same effect. For example: + + $ gh --%[2]s search issues -- "my search query -label:bug" + + See the following for more information: + - GitHub search syntax: + - The PowerShell stop parse flag %[1]s--%[2]s%[1]s: + - The Unix-like %[1]s--%[1]s argument: + `, "`", "%"), } cmd.AddCommand(searchCodeCmd.NewCmdCode(f, nil))