MCPcopy
hub / github.com/cli/cli / runLocalInstall

Function runLocalInstall

pkg/cmd/skills/install/install.go:482–573  ·  view source on GitHub ↗

runLocalInstall handles installation from a local directory path.

(opts *InstallOptions)

Source from the content-addressed store, hash-verified

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

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