cmdExecuteSingle runs the single block referenced by a numeric answer.
(ctx context.Context, renderer *agent.UIRenderer, blocks []CommandBlock, outputs []*CommandOutput, answer string, lastExecuted *int)
| 675 | |
| 676 | // cmdExecuteSingle runs the single block referenced by a numeric answer. |
| 677 | func (a *AgentMode) cmdExecuteSingle(ctx context.Context, renderer *agent.UIRenderer, blocks []CommandBlock, outputs []*CommandOutput, answer string, lastExecuted *int) { |
| 678 | cmdNum, err := strconv.Atoi(answer) |
| 679 | if err != nil || cmdNum < 1 || cmdNum > len(blocks) { |
| 680 | fmt.Println(i18n.T("agent.error.invalid_option")) |
| 681 | _ = a.getInput(renderer.Colorize(i18n.T("agent.status.press_enter"), agent.ColorGray)) |
| 682 | return |
| 683 | } |
| 684 | |
| 685 | execCtx, execCancel := context.WithTimeout(ctx, a.contextManager.GetDefaultTimeout()) |
| 686 | outStr, errStr := a.executeCommandsFunc(execCtx, blocks[cmdNum-1]) |
| 687 | execCancel() |
| 688 | |
| 689 | outputs[cmdNum-1] = &CommandOutput{ |
| 690 | CommandBlock: blocks[cmdNum-1], |
| 691 | Output: outStr, |
| 692 | ErrorMsg: errStr, |
| 693 | } |
| 694 | *lastExecuted = cmdNum - 1 |
| 695 | _ = a.getInput(renderer.Colorize(i18n.T("agent.status.press_enter"), agent.ColorGray)) |
| 696 | } |
| 697 | |
| 698 | // executeCommandsWithOutput executa comandos usando o CommandExecutor |
| 699 | func (a *AgentMode) executeCommandsWithOutput(ctx context.Context, block agent.CommandBlock) (string, string) { |
no test coverage detected