MCPcopy Create free account
hub / github.com/cli/cli / installRun

Function installRun

pkg/cmd/skills/install/install.go:254–455  ·  view source on GitHub ↗
(opts *InstallOptions)

Source from the content-addressed store, hash-verified

252}
253
254func installRun(opts *InstallOptions) error {
255 cs := opts.IO.ColorScheme()
256 canPrompt := opts.IO.CanPrompt()
257
258 if opts.localPath != "" {
259 return runLocalInstall(opts)
260 }
261
262 repo, repoSource, err := resolveRepoArg(opts.SkillSource, canPrompt, opts.Prompter)
263 if err != nil {
264 return err
265 }
266 opts.repo = repo
267 opts.SkillSource = repoSource
268
269 parseSkillFromOpts(opts)
270
271 httpClient, err := opts.HttpClient()
272 if err != nil {
273 return err
274 }
275 apiClient := api.NewClientFromHTTP(httpClient)
276
277 hostname := opts.repo.RepoHost()
278 if err := source.ValidateSupportedHost(hostname); err != nil {
279 return err
280 }
281
282 // Fetch the repository in parallel with resolving the version so the
283 // extra API roundtrip doesn't add latency on the critical path. Its ID
284 // is recorded with the installed skills, so that updates only come from
285 // this repository, and its visibility is used for telemetry.
286 type repoResult struct {
287 repo *discovery.Repository
288 err error
289 }
290 repoCh := make(chan repoResult, 1)
291 repoOwner, repoName := opts.repo.RepoOwner(), opts.repo.RepoName()
292 go func() {
293 repo, err := discovery.FetchRepository(apiClient, hostname, repoOwner, repoName)
294 repoCh <- repoResult{repo: repo, err: err}
295 }()
296
297 resolved, err := resolveVersion(opts, apiClient, hostname)
298 if err != nil {
299 return err
300 }
301
302 repoResp := <-repoCh
303 if repoResp.err != nil {
304 return fmt.Errorf("could not look up repository %s: %w", ghrepo.FullName(opts.repo), repoResp.err)
305 }
306 repository := repoResp.repo
307
308 var selectedSkills []discovery.Skill
309
310 if discovery.IsSkillPath(opts.SkillName) {
311 opts.IO.StartProgressIndicatorWithLabel("Looking up skill")

Calls 15

NewClientFromHTTPFunction · 0.92
ValidateSupportedHostFunction · 0.92
FetchRepositoryFunction · 0.92
FullNameFunction · 0.92
IsSkillPathFunction · 0.92
DiscoverSkillByPathFunction · 0.92
ResolveGitRootFunction · 0.92
ResolveHomeDirFunction · 0.92
InstallFunction · 0.92
ShortRefFunction · 0.92
CategorizeHostFunction · 0.92