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

Function runProviderWizard

internal/cli/provider_wizard.go:336–368  ·  view source on GitHub ↗

runProviderWizard is the entry point called from provider_cmd.go.

(
	out io.Writer,
	stdin io.Reader,
	mode wizardMode,
	existing *providers.Endpoint,
	existingName string,
	existingNames []string,
)

Source from the content-addressed store, hash-verified

334
335// runProviderWizard is the entry point called from provider_cmd.go.
336func runProviderWizard(
337 out io.Writer,
338 stdin io.Reader,
339 mode wizardMode,
340 existing *providers.Endpoint,
341 existingName string,
342 existingNames []string,
343) (name string, ep providers.Endpoint, cancelled bool, err error) {
344 file, ok := stdin.(*os.File)
345 if !ok || !isTerminal(file) {
346 hint := "cam provider add NAME --endpoint URL [--api-key-env VAR] ..."
347 if mode == wizardModeUpdate {
348 hint = "cam provider update NAME --endpoint URL [--description TEXT] ..."
349 }
350 return "", providers.Endpoint{}, false,
351 fmt.Errorf("interactive wizard requires a terminal; use flags instead:\n %s", hint)
352 }
353
354 model := newProviderWizardModel(mode, existing, existingName, existingNames)
355 program := tea.NewProgram(model, tea.WithOutput(out))
356 final, err := program.Run()
357 if err != nil {
358 return "", providers.Endpoint{}, false, err
359 }
360
361 wizard, ok := final.(providerWizardModel)
362 if !ok || wizard.aborted {
363 return "", providers.Endpoint{}, true, nil
364 }
365
366 n, e := wizard.result()
367 return n, e, false, nil
368}

Callers 2

providerAddCommandMethod · 0.85
providerUpdateCommandMethod · 0.85

Calls 4

isTerminalFunction · 0.85
newProviderWizardModelFunction · 0.85
resultMethod · 0.80
RunMethod · 0.65

Tested by

no test coverage detected