MCPcopy
hub / github.com/cli/cli / NewCmdOfficialExtensionStub

Function NewCmdOfficialExtensionStub

pkg/cmd/root/official_extension_stub.go:20–37  ·  view source on GitHub ↗

NewCmdOfficialExtensionStub creates a hidden stub command for an official extension that has not yet been installed. When invoked, it suggests installing the extension and, in interactive sessions, offers to do so immediately. After a successful install, the extension is dispatched with the original

(io *iostreams.IOStreams, p prompter.Prompter, em extensions.ExtensionManager, ext *extensions.OfficialExtension)

Source from the content-addressed store, hash-verified

18// immediately. After a successful install, the extension is dispatched with
19// the original arguments.
20func NewCmdOfficialExtensionStub(io *iostreams.IOStreams, p prompter.Prompter, em extensions.ExtensionManager, ext *extensions.OfficialExtension) *cobra.Command {
21 cmd := &cobra.Command{
22 Use: ext.Name,
23 Short: fmt.Sprintf("Install the official %s extension", ext.Name),
24 Hidden: true,
25 GroupID: "extension",
26 // Accept any args/flags the user may have passed so we don't get
27 // cobra validation errors before reaching RunE.
28 DisableFlagParsing: true,
29 RunE: func(cmd *cobra.Command, args []string) error {
30 return officialExtensionStubRun(io, p, em, ext)
31 },
32 }
33
34 cmdutil.DisableAuthCheck(cmd)
35
36 return cmd
37}
38
39func officialExtensionStubRun(io *iostreams.IOStreams, p prompter.Prompter, em extensions.ExtensionManager, ext *extensions.OfficialExtension) error {
40 stderr := io.ErrOut

Callers 2

NewCmdRootFunction · 0.85

Calls 2

DisableAuthCheckFunction · 0.92
officialExtensionStubRunFunction · 0.85