MCPcopy Create free account
hub / github.com/diillson/chatcli / cmdSaveOutput

Method cmdSaveOutput

cli/agent_command_blocks.go:418–435  ·  view source on GitHub ↗

cmdSaveOutput writes a previously captured output to a temp log file.

(renderer *agent.UIRenderer, outputs []*CommandOutput, answer string)

Source from the content-addressed store, hash-verified

416
417// cmdSaveOutput writes a previously captured output to a temp log file.
418func (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.
438func (a *AgentMode) cmdBatchExecute(ctx context.Context, renderer *agent.UIRenderer, blocks []CommandBlock, outputs []*CommandOutput, lastExecuted *int) {

Callers 1

handleCommandBlocksMethod · 0.95

Calls 3

getInputMethod · 0.95
TFunction · 0.92
ColorizeMethod · 0.80

Tested by

no test coverage detected