cmdSaveOutput writes a previously captured output to a temp log file.
(renderer *agent.UIRenderer, outputs []*CommandOutput, answer string)
| 416 | |
| 417 | // cmdSaveOutput writes a previously captured output to a temp log file. |
| 418 | func (a *AgentMode) cmdSaveOutput(renderer *agent.UIRenderer, outputs []*CommandOutput, answer string) { |
| 419 | nStr := strings.TrimPrefix(answer, "w") |
| 420 | n, err := strconv.Atoi(nStr) |
| 421 | if err != nil || n < 1 || n > len(outputs) || outputs[n-1] == nil { |
| 422 | fmt.Println(i18n.T("agent.status.no_output_to_save")) |
| 423 | _ = a.getInput(renderer.Colorize(i18n.T("agent.status.press_enter"), agent.ColorGray)) |
| 424 | return |
| 425 | } |
| 426 | dir := filepath.Join(os.TempDir(), "chatcli-agent-logs") |
| 427 | _ = os.MkdirAll(dir, 0o700) |
| 428 | fpath := filepath.Join(dir, fmt.Sprintf("cmd-%d-%d.log", n, time.Now().Unix())) |
| 429 | if writeErr := os.WriteFile(fpath, []byte(outputs[n-1].Output), 0o600); writeErr != nil { |
| 430 | fmt.Println(i18n.T("agent.status.error_saving"), writeErr) |
| 431 | } else { |
| 432 | fmt.Println(i18n.T("agent.status.file_saved_at"), fpath) |
| 433 | } |
| 434 | _ = a.getInput(renderer.Colorize(i18n.T("agent.status.press_enter"), agent.ColorGray)) |
| 435 | } |
| 436 | |
| 437 | // cmdBatchExecute runs every block in sequence after a confirmation prompt. |
| 438 | func (a *AgentMode) cmdBatchExecute(ctx context.Context, renderer *agent.UIRenderer, blocks []CommandBlock, outputs []*CommandOutput, lastExecuted *int) { |
no test coverage detected