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

Function buildInstallPlans

pkg/cmd/skills/install/install.go:986–1021  ·  view source on GitHub ↗
(opts *InstallOptions, selectedSkills []discovery.Skill, selectedHosts []*registry.AgentHost, scope registry.Scope, gitRoot, homeDir string, canPrompt bool)

Source from the content-addressed store, hash-verified

984}
985
986func buildInstallPlans(opts *InstallOptions, selectedSkills []discovery.Skill, selectedHosts []*registry.AgentHost, scope registry.Scope, gitRoot, homeDir string, canPrompt bool) ([]installPlan, error) {
987 byDir := make(map[string]*installPlan)
988 orderedDirs := make([]string, 0, len(selectedHosts))
989
990 for _, host := range selectedHosts {
991 targetDir, err := resolveInstallDir(opts, host, scope, gitRoot, homeDir)
992 if err != nil {
993 return nil, err
994 }
995
996 plan, ok := byDir[targetDir]
997 if !ok {
998 plan = &installPlan{dir: targetDir}
999 byDir[targetDir] = plan
1000 orderedDirs = append(orderedDirs, targetDir)
1001 }
1002 plan.hosts = append(plan.hosts, host)
1003 }
1004
1005 plans := make([]installPlan, 0, len(orderedDirs))
1006 for _, dir := range orderedDirs {
1007 plan := byDir[dir]
1008 installSkills, err := checkOverwrite(opts, selectedSkills, plan.dir, canPrompt)
1009 if err != nil {
1010 return nil, err
1011 }
1012 if len(installSkills) == 0 {
1013 fmt.Fprintf(opts.IO.ErrOut, "No skills to install in %s for %s.\n", friendlyDir(plan.dir), formatPlanHosts(plan.hosts))
1014 continue
1015 }
1016 plan.skills = installSkills
1017 plans = append(plans, *plan)
1018 }
1019
1020 return plans, nil
1021}
1022
1023func resolveInstallDir(opts *InstallOptions, host *registry.AgentHost, scope registry.Scope, gitRoot, homeDir string) (string, error) {
1024 if opts.Dir != "" {

Callers 2

installRunFunction · 0.85
runLocalInstallFunction · 0.85

Calls 4

resolveInstallDirFunction · 0.85
checkOverwriteFunction · 0.85
friendlyDirFunction · 0.85
formatPlanHostsFunction · 0.85

Tested by

no test coverage detected