(ctx context.Context, userInput string)
| 346 | } |
| 347 | |
| 348 | func (cli *ChatCLI) handleSwitchCommand(ctx context.Context, userInput string) { |
| 349 | args := strings.Fields(userInput) |
| 350 | var newModel, newRealm, newAgentID string |
| 351 | shouldSwitchModel, shouldUpdateStackSpot := false, false |
| 352 | maxTokensOverride := -1 |
| 353 | |
| 354 | listModels := false |
| 355 | for i := 1; i < len(args); i++ { |
| 356 | switch args[i] { |
| 357 | case "--model": |
| 358 | if i+1 < len(args) { |
| 359 | newModel = args[i+1] |
| 360 | shouldSwitchModel = true |
| 361 | i++ // Pular o valor |
| 362 | } else { |
| 363 | listModels = true |
| 364 | } |
| 365 | case "--max-tokens": |
| 366 | if i+1 < len(args) { |
| 367 | val, err := strconv.Atoi(args[i+1]) |
| 368 | if err == nil && val >= 0 { |
| 369 | maxTokensOverride = val |
| 370 | } else { |
| 371 | fmt.Println(i18n.T("cli.switch.invalid_max_tokens", args[i+1])) |
| 372 | } |
| 373 | i++ |
| 374 | } |
| 375 | case "--realm": |
| 376 | if i+1 < len(args) { |
| 377 | newRealm = args[i+1] |
| 378 | shouldUpdateStackSpot = true |
| 379 | i++ |
| 380 | } |
| 381 | case "--agent-id": |
| 382 | if i+1 < len(args) { |
| 383 | newAgentID = args[i+1] |
| 384 | shouldUpdateStackSpot = true |
| 385 | i++ |
| 386 | } |
| 387 | } |
| 388 | } |
| 389 | if maxTokensOverride != -1 { |
| 390 | cli.UserMaxTokens = maxTokensOverride |
| 391 | fmt.Println(i18n.T("cli.switch.max_tokens_set", cli.UserMaxTokens)) |
| 392 | } |
| 393 | |
| 394 | if shouldUpdateStackSpot { |
| 395 | if cli.Provider != "STACKSPOT" { |
| 396 | fmt.Println(i18n.T("cli.switch.stackspot_only_flags")) |
| 397 | return |
| 398 | } |
| 399 | if newRealm != "" { |
| 400 | cli.manager.SetStackSpotRealm(newRealm) |
| 401 | fmt.Println(i18n.T("cli.switch.realm_updated", newRealm)) |
| 402 | } |
| 403 | if newAgentID != "" { |
| 404 | cli.manager.SetStackSpotAgentID(newAgentID) |
| 405 | newClient, err := cli.manager.GetClient("STACKSPOT", "") |
no test coverage detected