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

Function buildInstallPlans

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

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