Run a command in an Apple development environment. Optionally logs the executed command to the console.
(
command: ArgsT,
*,
host: str | None = None,
env: EnvironmentT | None = None,
log: bool | None = True,
**kwargs,
)
| 93 | |
| 94 | |
| 95 | def run( |
| 96 | command: ArgsT, |
| 97 | *, |
| 98 | host: str | None = None, |
| 99 | env: EnvironmentT | None = None, |
| 100 | log: bool | None = True, |
| 101 | **kwargs, |
| 102 | ) -> subprocess.CompletedProcess: |
| 103 | """Run a command in an Apple development environment. |
| 104 | |
| 105 | Optionally logs the executed command to the console. |
| 106 | """ |
| 107 | kwargs.setdefault("check", True) |
| 108 | if env is None: |
| 109 | env = os.environ.copy() |
| 110 | |
| 111 | if host: |
| 112 | host_env = apple_env(host) |
| 113 | print_env(host_env) |
| 114 | env.update(host_env) |
| 115 | |
| 116 | if log: |
| 117 | print(">", join_command(command)) |
| 118 | return subprocess.run(command, env=env, **kwargs) |
| 119 | |
| 120 | |
| 121 | def join_command(args: str | Path | ArgsT) -> str: |
no test coverage detected