MCPcopy Index your code
hub / github.com/cli/cli / buildInstallPlans

Function buildInstallPlans

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

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