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

Function runLocalInstall

pkg/cmd/skills/install/install.go:487–578  ·  view source on GitHub ↗

runLocalInstall handles installation from a local directory path.

(opts *InstallOptions)

Source from the content-addressed store, hash-verified

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

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