You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Watch the current directory with a safe pathless default:
36
+
37
+
```bash
38
+
with-watch ls -l
39
+
```
40
+
41
+
Run a simple shell expression:
42
+
43
+
```bash
44
+
with-watch --shell 'cat input.txt | grep hello'
45
+
```
46
+
47
+
Provide explicit inputs for an arbitrary command:
48
+
49
+
```bash
50
+
with-watch exec --input 'src/**/*.rs' -- cargo test -p with-watch
51
+
```
52
+
53
+
## Input inference model
54
+
55
+
- Passthrough mode and `--shell` use built-in command adapters first.
56
+
- Known outputs, inline scripts, and output redirects are filtered out of the watch set.
57
+
- Safe pathless defaults are intentionally narrow: `ls`, `dir`, `vdir`, `du`, and `find`.
58
+
- If `with-watch` cannot infer safe filesystem inputs, it fails instead of guessing.
59
+
60
+
## When exec --input is required
61
+
62
+
Some commands do not expose meaningful filesystem inputs on their own. For example, `echo hello` has nothing safe to watch.
63
+
64
+
In those cases, use `exec --input` to declare the watch set explicitly:
65
+
66
+
```bash
67
+
with-watch exec --input 'src/**/*.rs' -- cargo test -p with-watch
68
+
```
69
+
70
+
`with-watch` reruns the delegated command unchanged. It does not inject changed file paths into argv or environment variables.
71
+
72
+
## Shell support boundaries
73
+
74
+
-`--shell` supports command-line expressions with `&&`, `||`, and `|`.
75
+
- Input redirects (`<`, `<>`) become watched inputs.
76
+
- Output redirects (`>`, `>>`, `&>`, `&>>`, `>|`) are treated as outputs and filtered from watching.
77
+
- Full shell control-flow is out of scope for v1.
78
+
79
+
## Rerun behavior
80
+
81
+
- Default rerun filtering uses content hashes.
82
+
-`--no-hash` switches to metadata-only comparison.
83
+
- Self-mutating commands such as `sed -i.bak -e 's/old/new/' config.txt` refresh their baseline after each run so they do not loop on their own writes.
84
+
- Replace-style writers remain watchable because path inputs subscribe from the nearest existing directory anchor.
Use passthrough mode for a single delegated command, shell mode for simple command-line expressions that need `&&`, `||`, or `|`, and `exec --input` when you want to declare the watched files yourself.
- Known outputs, inline scripts, patterns, and shell output redirects are filtered out of the watch set.
26
41
- Pathless defaults are intentionally narrow: only `ls`, `dir`, `vdir`, `du`, and `find` implicitly watch the current directory.
27
42
-`exec --input` remains the explicit escape hatch when a delegated command has no meaningful filesystem inputs or when fallback inference would be ambiguous.
43
+
44
+
## When to use exec --input
45
+
46
+
Use `exec --input` when the delegated command does not read a stable filesystem input by itself, or when you want the watch set to be explicit.
47
+
48
+
For example, commands like `echo hello` are intentionally rejected because there is nothing safe to watch:
49
+
50
+
```sh
51
+
with-watch exec --input 'src/**/*.rs' -- cargo test -p with-watch
52
+
```
53
+
54
+
`with-watch` reruns the delegated command exactly as provided. It does not inject changed paths into argv or environment variables.
55
+
56
+
## Shell limitations
57
+
58
+
-`--shell` is for command-line expressions, not shell scripts.
59
+
- Supported operators are `&&`, `||`, and `|`.
60
+
- Input redirects (`<`, `<>`) are treated as watched inputs.
61
+
- Output redirects (`>`, `>>`, `&>`, `&>>`, `>|`) are filtered as outputs and are not watched.
62
+
- Broader shell control-flow remains out of scope for v1.
63
+
64
+
## Rerun behavior
65
+
66
+
- The default rerun filter compares content hashes, which avoids reruns from metadata churn alone.
67
+
-`--no-hash` switches the filter to metadata-only comparison.
68
+
- Commands that write excluded outputs such as `cp src.txt dest.txt` should rerun when the source input changes, not when the output file changes.
69
+
- Commands that mutate watched inputs directly, such as `sed -i.bak -e 's/old/new/' config.txt`, refresh their baseline after each run so they do not loop on their own writes.
70
+
- Path-based inputs anchor the watcher at the nearest existing directory so replace-style writers keep producing later external change events.
71
+
72
+
## Troubleshooting
73
+
74
+
-`No watch inputs could be inferred from the delegated command`: switch to `with-watch exec --input ... -- <command>`.
75
+
-`--shell cannot be combined with delegated argv or the exec subcommand`: choose exactly one command mode per invocation.
76
+
-`--shell` works only for simple command-line expressions on Unix-like platforms.
Copy file name to clipboardExpand all lines: docs/apps-public-docs-foundation.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,6 +15,8 @@
15
15
## Interfaces and Contracts
16
16
- Navigation and page ID contracts in `apps/public-docs/docs.json` must remain stable.
17
17
- Public-facing routes and content groupings must map to canonical docs contracts.
18
+
- Top-level product page IDs currently include `nodeup`, `cargo-mono`, `derun`, `with-watch`, and `dexdex`.
19
+
- The `With Watch` tab must route to the stable page ID `with-watch` and keep the `Command Rerun Watcher` grouping unless contracts are updated together.
- The CLI must continue to reject mixed modes and empty delegated-command requests with operator-facing guidance.
21
+
- Passthrough and shell modes must infer watch inputs before the first run; if inference does not produce safe filesystem inputs, the command must fail with `exec --input` guidance instead of guessing.
22
+
-`exec --input` must accept repeatable explicit glob/path values, keep the delegated command unchanged, and remain the canonical fallback for otherwise ambiguous or pathless commands.
23
+
-`--no-hash` must remain a global flag that switches rerun filtering from content hashes to metadata-only comparison.
20
24
- Public crate installation must remain `cargo install with-watch`.
21
25
- Publish tag naming must remain `with-watch@v<version>`.
22
26
- Stable internal enums must remain aligned with the current v1 contract:
@@ -36,6 +40,7 @@
36
40
-`exec --input` remains the canonical explicit input contract when inference is insufficient, but command-side side-effect metadata may still be inferred for rerun suppression and logging.
37
41
- Commands marked as `WritesWatchedInputs` must refresh the baseline snapshot after each run and suppress reruns caused only by their own writes while they were executing.
38
42
- Path watch inputs must attach their OS watcher to the nearest existing directory so replace-style writers such as GNU `sed -i` do not orphan follow-up change detection on Linux.
43
+
- Operator-facing documentation must explain the three command modes, the `exec --input` escape hatch, shell support boundaries, and why self-mutating commands do not loop on their own writes.
39
44
- Homebrew installation must consume prebuilt GitHub release archives for `darwin/amd64`, `darwin/arm64`, and `linux/amd64`.
40
45
41
46
## Storage
@@ -56,6 +61,7 @@
56
61
- Local validation: `cargo test -p with-watch`
57
62
- Workspace validation baseline: `cargo test --workspace --all-targets`
- Documentation changes should be checked against `cargo run -p with-watch -- --help` and the integration scenarios in `crates/with-watch/tests/cli.rs`.
- Release contract checks should align with `.github/workflows/release-with-watch.yml`.
61
67
- Release assets must include standalone binaries (`with-watch-<os>-<arch>[.exe]`) and compressed archives (`with-watch-<os>-<arch>.tar.gz|zip`) for the supported release matrix.
- The public CLI surface must keep exactly one delegated-command entrypoint per invocation: passthrough argv, `--shell`, or `exec --input`.
19
20
- Default change detection must prefer content hashing, while `--no-hash` must switch the rerun filter to metadata-only comparison.
20
21
-`exec --input` reruns the delegated command unchanged and must not inject changed paths into argv or environment variables.
22
+
- Commands without safe inferred filesystem inputs must fail clearly and direct operators to `with-watch exec --input ...`.
21
23
- Passthrough and shell modes must use adapter-driven input inference that excludes known outputs, scripts, and pattern operands from the watch set.
22
24
- Shell redirects must treat `<` and `<>` targets as watched inputs and `>`, `>>`, `&>`, `&>>`, and `>|` targets as filtered outputs.
25
+
- Shell parsing support is limited to command-line expressions plus `&&`, `||`, and `|`; broader shell control-flow stays out of scope until documented otherwise.
23
26
- Safe pathless default watch roots are limited to the built-in allowlist (`ls`, `dir`, `vdir`, `du`, and `find`).
24
27
- Commands that mutate watched inputs directly must refresh the baseline snapshot after each run and suppress self-triggered reruns caused by their own writes.
25
28
- Path-based watch inputs must anchor watcher subscriptions at the nearest existing directory so replace-style writers keep emitting later external changes.
@@ -29,7 +32,7 @@ Provide a Rust-based CLI wrapper that reruns delegated shell utilities and arbit
29
32
- Homebrew installation must consume prebuilt `with-watch` release archives for `darwin/amd64`, `darwin/arm64`, and `linux/amd64`.
30
33
31
34
## Change Policy
32
-
- Update this index and `docs/crates-with-watch-foundation.md` together when CLI shape, watch inference behavior, release automation, side-effect suppression, or storage/logging contracts change.
35
+
- Update this index and `docs/crates-with-watch-foundation.md` together when CLI shape, watch inference behavior, operator guidance, release automation, side-effect suppression, or storage/logging contracts change.
33
36
- Update root `Cargo.toml`, `.github/workflows/release-with-watch.yml`, `scripts/release/update-homebrew.sh`, and `packaging/homebrew/templates/with-watch.rb.tmpl` in the same change when with-watch release tags, artifact names, or package-manager distribution contracts change.
34
37
- Keep root `AGENTS.md` and `crates/AGENTS.md` aligned with ownership and project-ID changes.
0 commit comments