Print and optionally execute a shell command.
(cmd, *, cwd, dry_run=False, check=True, capture=False)
| 43 | |
| 44 | |
| 45 | def run(cmd, *, cwd, dry_run=False, check=True, capture=False): |
| 46 | """Print and optionally execute a shell command.""" |
| 47 | print(f" $ {' '.join(str(c) for c in cmd)}") |
| 48 | if dry_run: |
| 49 | return subprocess.CompletedProcess(cmd, 0, stdout="", stderr="") |
| 50 | return subprocess.run( |
| 51 | cmd, cwd=cwd, capture_output=capture, text=True, check=check, |
| 52 | ) |
| 53 | |
| 54 | |
| 55 | def git(args, *, cwd, dry_run=False, check=True, capture=False): |
no test coverage detected