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

Function resolveHosts

pkg/cmd/skills/install/install.go:909–952  ·  view source on GitHub ↗
(opts *InstallOptions, canPrompt bool)

Source from the content-addressed store, hash-verified

907}
908
909func resolveHosts(opts *InstallOptions, canPrompt bool) ([]*registry.AgentHost, error) {
910 if opts.Agent != "" {
911 h, err := registry.FindByID(opts.Agent)
912 if err != nil {
913 return nil, err
914 }
915 return []*registry.AgentHost{h}, nil
916 }
917
918 if !canPrompt {
919 h, err := registry.FindByID(registry.DefaultAgentID)
920 if err != nil {
921 return nil, err
922 }
923 return []*registry.AgentHost{h}, nil
924 }
925
926 fmt.Fprintln(opts.IO.ErrOut)
927 labels := make([]string, len(registry.Agents))
928 defaultLabel := ""
929 for i, h := range registry.Agents {
930 labels[i] = h.Name
931 if h.ID == registry.DefaultAgentID {
932 defaultLabel = labels[i]
933 }
934 }
935 if defaultLabel == "" {
936 defaultLabel = labels[0]
937 }
938 indices, err := opts.Prompter.MultiSelect("Select target agent(s):", []string{defaultLabel}, labels)
939 if err != nil {
940 return nil, err
941 }
942
943 if len(indices) == 0 {
944 return nil, fmt.Errorf("must select at least one target agent")
945 }
946
947 selected := make([]*registry.AgentHost, len(indices))
948 for i, idx := range indices {
949 selected[i] = &registry.Agents[idx]
950 }
951 return selected, nil
952}
953
954func resolveScope(opts *InstallOptions, canPrompt bool) (registry.Scope, error) {
955 if opts.Dir != "" {

Callers 2

installRunFunction · 0.85
runLocalInstallFunction · 0.85

Calls 3

FindByIDFunction · 0.92
MultiSelectMethod · 0.65
ErrorfMethod · 0.65

Tested by

no test coverage detected