MCPcopy Create free account
hub / github.com/Ishabdullah/Codey-v2 / _run_basic_fallback

Function _run_basic_fallback

core/peer_shell.py:482–508  ·  view source on GitHub ↗

Fallback when pexpect is not installed. Opens CLI with tee capture; user must type the prompt manually.

(cli_name: str, cmd: str, prompt_text: str)

Source from the content-addressed store, hash-verified

480
481
482def _run_basic_fallback(cli_name: str, cmd: str, prompt_text: str) -> str:
483 """
484 Fallback when pexpect is not installed.
485 Opens CLI with tee capture; user must type the prompt manually.
486 """
487 import tempfile
488 width = _terminal_width()
489 outfile = tempfile.mktemp(prefix="codey_peer_", suffix=".txt")
490
491 print(f"\n{_CYAN}{_header(cli_name.upper() + ' CLI (manual mode)', width)}{_RESET}")
492 if prompt_text:
493 print(f"\n{_DIM}── Paste this into {cli_name} ──{_RESET}")
494 print(f"{_DIM}{prompt_text}{_RESET}")
495 print(f"{_DIM}{'─' * width}{_RESET}\n")
496
497 os.system(f'{cmd} 2>&1 | tee "{outfile}"')
498
499 print(f"\n{_CYAN}{_header(cli_name.upper() + ' DONE', width)}{_RESET}\n")
500 info(f"Reading {cli_name} output…")
501
502 try:
503 import pathlib
504 out = pathlib.Path(outfile).read_text(encoding="utf-8", errors="replace")
505 pathlib.Path(outfile).unlink(missing_ok=True)
506 return out
507 except Exception:
508 return ""

Callers 1

run_peerFunction · 0.85

Calls 3

infoFunction · 0.90
_terminal_widthFunction · 0.85
_headerFunction · 0.85

Tested by

no test coverage detected