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

Function runLocalInstall

pkg/cmd/skills/install/install.go:474–565  ·  view source on GitHub ↗

runLocalInstall handles installation from a local directory path.

(opts *InstallOptions)

Source from the content-addressed store, hash-verified

472
473// runLocalInstall handles installation from a local directory path.
474func runLocalInstall(opts *InstallOptions) error {
475 cs := opts.IO.ColorScheme()
476 canPrompt := opts.IO.CanPrompt()
477 sourcePath := opts.localPath
478 if sourcePath == "~" {
479 if home, err := os.UserHomeDir(); err == nil {
480 sourcePath = home
481 }
482 } else if after, ok := strings.CutPrefix(sourcePath, "~/"); ok {
483 if home, err := os.UserHomeDir(); err == nil {
484 sourcePath = filepath.Join(home, after)
485 }
486 }
487
488 absSource, err := filepath.Abs(sourcePath)
489 if err != nil {
490 return fmt.Errorf("could not resolve path: %w", err)
491 }
492
493 opts.IO.StartProgressIndicatorWithLabel("Discovering skills")
494 allSkills, err := discovery.DiscoverLocalSkillsWithOptions(absSource, discovery.DiscoverOptions{})
495 opts.IO.StopProgressIndicator()
496 if err != nil {
497 return err
498 }
499
500 skills, err := filterHiddenDirSkills(opts, allSkills)
501 if err != nil {
502 return err
503 }
504
505 if canPrompt {
506 fmt.Fprintf(opts.IO.ErrOut, "Found %d skill(s)\n", len(skills))
507 }
508
509 selectedSkills, err := selectSkillsWithSelector(opts, skills, canPrompt, skillSelector{
510 matchByName: matchLocalSkillByName,
511 sourceHint: absSource,
512 })
513 if err != nil {
514 if errors.Is(err, errSkillsListed) {
515 return nil
516 }
517 return err
518 }
519
520 printPreInstallDisclaimer(opts.IO.ErrOut, cs)
521
522 selectedHosts, err := resolveHosts(opts, canPrompt)
523 if err != nil {
524 return err
525 }
526
527 scope, err := resolveScope(opts, canPrompt)
528 if err != nil {
529 return err
530 }
531

Callers 1

installRunFunction · 0.85

Calls 15

ResolveGitRootFunction · 0.92
ResolveHomeDirFunction · 0.92
InstallLocalFunction · 0.92
selectSkillsWithSelectorFunction · 0.85
resolveHostsFunction · 0.85
resolveScopeFunction · 0.85
buildInstallPlansFunction · 0.85
friendlyDirFunction · 0.85
formatPlanHostsFunction · 0.85
printFileTreeFunction · 0.85

Tested by

no test coverage detected