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

Function buildInstallPlans

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

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