MCPcopy Create free account
hub / github.com/Chat2AnyLLM/code-agent-manager / handleEndpointsShortCircuit

Function handleEndpointsShortCircuit

internal/cli/global.go:41–68  ·  view source on GitHub ↗
(cmd *cobra.Command, state *globalState)

Source from the content-addressed store, hash-verified

39var errEndpointsHandled = errors.New("cli: --endpoints handled")
40
41func handleEndpointsShortCircuit(cmd *cobra.Command, state *globalState) error {
42 if state.endpoints == "" {
43 return nil
44 }
45 file, err := makeProviderAPI(state).File(context.Background())
46 if err != nil {
47 return err
48 }
49 out := cmd.OutOrStdout()
50 target := state.endpoints
51 if target == "all" {
52 printEndpointTable(out, file)
53 return errEndpointsHandled
54 }
55 matches := map[string]providers.Endpoint{}
56 for _, name := range file.SortedNames() {
57 ep := file.Endpoints[name]
58 if ep.SupportsClient(target) {
59 matches[name] = ep
60 }
61 }
62 if len(matches) == 0 {
63 return fmt.Errorf("No endpoints support client: %s", target)
64 }
65 subset := providers.File{Common: file.Common, Endpoints: matches}
66 printEndpointTable(out, subset)
67 return errEndpointsHandled
68}
69
70func printEndpointTable(out interface{ Write(p []byte) (int, error) }, file providers.File) {
71 fmt.Fprintf(out, "Endpoints: %d\n", len(file.Endpoints))

Callers 1

rootCommandMethod · 0.85

Calls 5

makeProviderAPIFunction · 0.85
printEndpointTableFunction · 0.85
FileMethod · 0.80
SortedNamesMethod · 0.80
SupportsClientMethod · 0.80

Tested by

no test coverage detected