(opts *InstallOptions, selectedSkills []discovery.Skill, selectedHosts []*registry.AgentHost, scope registry.Scope, gitRoot, homeDir string, canPrompt bool)
| 987 | } |
| 988 | |
| 989 | func 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 | |
| 1026 | func resolveInstallDir(opts *InstallOptions, host *registry.AgentHost, scope registry.Scope, gitRoot, homeDir string) (string, error) { |
| 1027 | if opts.Dir != "" { |
no test coverage detected