Backup Termux settings (NOT packages). Produces a tar.gz containing known config files that this tool may change.
()
| 384 | ) -> subprocess.CompletedProcess: |
| 385 | command_text = quote_cmd(args) |
| 386 | log_line(f"$ {command_text}") |
| 387 | kwargs = { |
| 388 | "cwd": str(cwd) if cwd else None, |
| 389 | "env": env, |
| 390 | "text": True, |
| 391 | } |
| 392 | if capture: |
| 393 | kwargs.update({"stdout": subprocess.PIPE, "stderr": subprocess.PIPE}) |
| 394 | result = subprocess.run(args, **kwargs) |
| 395 | if capture: |
| 396 | if result.stdout: |
| 397 | log_line(result.stdout) |
| 398 | if result.stderr: |
| 399 | log_line(result.stderr) |
| 400 | if check and result.returncode != 0: |
| 401 | raise RuntimeError(f"Command failed ({result.returncode}): {command_text}") |
| 402 | return result |
| 403 | |
| 404 | |
| 405 | def run_shell(command: str, *, check: bool = False, capture: bool = False) -> subprocess.CompletedProcess: |
| 406 | return run_cmd(["bash", "-lc", command], check=check, capture=capture) |
| 407 | |
| 408 | |
| 409 | def ask_yes_no(prompt: str, default: bool = True) -> bool: |
| 410 | if ASSUME_YES: |
| 411 | return True |
| 412 | if NON_INTERACTIVE: |
| 413 | return default |
| 414 | suffix = " [Y/n] " if default else " [y/N] " |
| 415 | while True: |
| 416 | answer = input(c(prompt + suffix, C.INFO)).strip().lower() |
| 417 | if not answer: |
| 418 | return default |
| 419 | if answer in {"y", "yes"}: |
| 420 | return True |
| 421 | if answer in {"n", "no"}: |
| 422 | return False |
| 423 | print(c("Please answer y or n.", C.WARN)) |
no test coverage detected