Skip to content

Commit 3f4f834

Browse files
committed
docs(migrating): faithful returncode==0 mapping + verb-raise caveats
1 parent ae783ab commit 3f4f834

1 file changed

Lines changed: 13 additions & 3 deletions

File tree

docs/migrating.md

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ See [Picking a verb](commands.md#picking-a-verb) for the full set.
3030
|---|---|
3131
| `run(cmd, capture_output=True, text=True)` → inspect `.returncode` / `.stdout` | `Command(prog, args).output()``ProcessResult` (`.code`, `.stdout`, `.is_success`, `.timed_out`) |
3232
| `run(cmd, capture_output=True, text=True, check=True).stdout` | `Command(prog, args).run()` (returns **trimmed** stdout, raises on failure) |
33-
| `run(cmd).returncode` | `Command(prog, args).exit_code()` |
34-
| `run(cmd).returncode == 0` | `Command(prog, args).probe()` (`True`/`False`) |
33+
| `run(cmd).returncode` | `Command(prog, args).exit_code()` (raw code) |
34+
| `run(cmd).returncode == 0` | `Command(prog, args).output().is_success` (total); `.probe()` is a shortcut for `0`/`1`-exit predicate tools |
3535
| `run(cmd, capture_output=True).stdout` (bytes) | `Command(prog, args).output_bytes()``BytesResult` (`.stdout` is `bytes`) |
3636

3737
```python
@@ -50,6 +50,12 @@ Note the two differences from `run()` in `subprocess`: `.output().stdout` is the
5050
it **trimmed**; and a non-zero exit is only an error for `.run()`, never for
5151
`.output()`.
5252

53+
One more divergence to know: unlike `subprocess`'s numeric `.returncode`, the
54+
*checking* verbs (`exit_code`, `probe`, `run`) **raise** on a timeout or a
55+
signal-kill instead of returning a code (and `probe()` also raises on any exit code
56+
other than `0`/`1`). Reach for `.output()` when you want an abnormal exit as
57+
inspectable data (`.timed_out`, `.signal`) rather than an exception.
58+
5359
## The common flags
5460

5561
| `subprocess` keyword | `processkit` builder |
@@ -59,7 +65,7 @@ it **trimmed**; and a non-zero exit is only an error for `.run()`, never for
5965
| `cwd="/path"` | `.cwd("/path")` |
6066
| `env={...}` (**replaces** the whole environment) | `.env_clear().envs({...})` |
6167
| add/override one variable on the inherited env | `.env("KEY", "value")` / `.envs({...})` |
62-
| — (no equivalent) | `.success_codes([0, 1])`treat listed codes as success (`grep`/`diff`) |
68+
| — (no equivalent) | `.success_codes([0, 1])`**replaces** the success set with the listed codes (`grep`/`diff`) |
6369

6470
```python
6571
# subprocess: subprocess.run(["slow"], timeout=5) -> raises TimeoutExpired
@@ -173,3 +179,7 @@ that never spawn children of their own, don't need async cancellation to be
173179
leak-safe, and want zero third-party dependencies, the stdlib is a perfectly good
174180
choice — `processkit` is deliberately **not** a general `subprocess`-convenience
175181
replacement. The wedge is the no-orphan guarantee.
182+
183+
---
184+
185+
Next: [Running commands](commands.md) · [Cookbook](cookbook.md)

0 commit comments

Comments
 (0)