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)
| 18 | // immediately. After a successful install, the extension is dispatched with |
| 19 | // the original arguments. |
| 20 | func 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 | |
| 39 | func officialExtensionStubRun(io *iostreams.IOStreams, p prompter.Prompter, em extensions.ExtensionManager, ext *extensions.OfficialExtension) error { |
| 40 | stderr := io.ErrOut |