Register hidden stub commands for official GitHub extensions (gh-aw, gh-stack) that offer to install the extension when invoked. This replaces the error-string-matching approach from the original PR with proper cobra commands that: - Avoid false-positive matches on flag values or post-'--' args - Eliminate conflicting cobra 'Did you mean?' suggestions - Properly propagate prompt/install errors for correct exit codes - Are hidden from help output and shell completions - Use GroupID "extension" so checkValidExtension allows installing over them - Are registered after extensions and aliases so both take priority Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
26 lines
845 B
Go
26 lines
845 B
Go
package extensions
|
|
|
|
import (
|
|
"github.com/cli/cli/v2/internal/ghrepo"
|
|
)
|
|
|
|
// OfficialExtension describes a GitHub-owned CLI extension that can be
|
|
// suggested to users when they invoke an unknown command.
|
|
type OfficialExtension struct {
|
|
Name string
|
|
Owner string
|
|
Repo string
|
|
}
|
|
|
|
// Repository returns a ghrepo.Interface pinned to github.com so that GHES
|
|
// users install from github.com rather than their enterprise host.
|
|
func (e *OfficialExtension) Repository() ghrepo.Interface {
|
|
return ghrepo.NewWithHost(e.Owner, e.Repo, "github.com")
|
|
}
|
|
|
|
// OfficialExtensions is the registry of GitHub-owned extensions that gh will
|
|
// offer to install when the user invokes the corresponding command name.
|
|
var OfficialExtensions = []OfficialExtension{
|
|
{Name: "aw", Owner: "github", Repo: "gh-aw"},
|
|
{Name: "stack", Owner: "github", Repo: "gh-stack"},
|
|
}
|