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

Function buildInstallPlans

pkg/cmd/skills/install/install.go:987–1022  ·  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

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