Skip to content

Commit 70dfc86

Browse files
committed
with-watch: add common search and codegen adapters
1 parent 9854f88 commit 70dfc86

File tree

6 files changed

+1115
-106
lines changed

6 files changed

+1115
-106
lines changed

apps/public-docs/with-watch.mdx

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ It performs one initial run immediately after input inference, watcher setup, an
66

77
## Why use with-watch
88

9-
- Keep familiar CLI tools such as `cat`, `cp`, `sed`, and `find`.
10-
- Let `with-watch` infer watched inputs for common file-oriented commands.
9+
- Keep familiar CLI tools such as `cat`, `cp`, `sed`, `rg`, `protoc`, and `find`.
10+
- Let `with-watch` infer watched inputs for common file-oriented, search, and schema/codegen commands.
1111
- Declare explicit inputs with `exec --input` when you want fully predictable reruns.
1212

1313
## Install
@@ -56,12 +56,24 @@ Watch the current directory with a safe pathless default:
5656
with-watch ls -l
5757
```
5858

59+
Search a source tree without watching the pattern itself:
60+
61+
```bash
62+
with-watch rg TODO src
63+
```
64+
5965
Run a simple shell expression:
6066

6167
```bash
6268
with-watch --shell 'cat input.txt | grep hello'
6369
```
6470

71+
Watch proto inputs and rerun codegen when schemas change:
72+
73+
```bash
74+
with-watch protoc -I proto proto/service.proto --go_out gen
75+
```
76+
6577
Provide explicit inputs for an arbitrary command:
6678

6779
```bash
@@ -72,6 +84,8 @@ with-watch exec --input 'src/**/*.rs' -- cargo test -p with-watch
7284

7385
- Passthrough mode and `--shell` use built-in command adapters first.
7486
- Known outputs, inline scripts, and output redirects are filtered out of the watch set.
87+
- Search adapters such as `rg`, `ag`, and `fd` watch explicit search roots and file-valued pattern/ignore inputs without treating patterns, globs, or type filters as watched paths.
88+
- Schema/codegen adapters such as `protoc`, `flatc`, `thrift`, and `capnp compile` watch source files plus include/import roots while filtering output directories and generated artifacts.
7589
- Safe pathless defaults are intentionally narrow: `ls`, `dir`, `vdir`, `du`, and `find`.
7690
- If `with-watch` cannot infer safe filesystem inputs, it fails instead of guessing.
7791

@@ -87,10 +101,10 @@ Dedicated built-in adapters and aliases:
87101

88102
- `cp`, `mv`, `install`, `ln`, `link`, `rm`, `unlink`, `rmdir`, `shred`
89103
- `sort`, `uniq`, `split`, `csplit`, `tee`
90-
- `grep`, `egrep`, `fgrep`, `sed`
104+
- `grep`, `egrep`, `fgrep`, `rg`, `ag`, `sed`
91105
- `awk`, `gawk`, `mawk`, `nawk`
92-
- `find`, `xargs`, `tar`, `touch`, `truncate`
93-
- `chmod`, `chown`, `chgrp`, `dd`
106+
- `find`, `fd`, `xargs`, `tar`, `touch`, `truncate`
107+
- `chmod`, `chown`, `chgrp`, `dd`, `protoc`, `flatc`, `thrift`, `capnp`
94108

95109
Generic read-path commands:
96110

crates/with-watch/README.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ It executes the delegated command once immediately after input inference, watche
77
## Why use
88

99
- Keep familiar POSIX/coreutils-style commands while adding automatic reruns.
10-
- Let `with-watch` infer watched inputs for common read/write utilities such as `cat`, `cp`, `sed`, and `find`.
10+
- Let `with-watch` infer watched inputs for common read/write utilities, search tools, and schema/codegen commands such as `cat`, `rg`, `fd`, `protoc`, and `find`.
1111
- Fall back to explicit `exec --input` globs when inference would be ambiguous or when the delegated command has no meaningful filesystem inputs.
1212

1313
## Install
@@ -57,7 +57,9 @@ with-watch cat input.txt
5757
with-watch --clear cat input.txt
5858
with-watch cp src.txt dest.txt
5959
with-watch ls -l
60+
with-watch rg TODO src
6061
with-watch --shell 'cat src.txt | grep hello'
62+
with-watch protoc -I proto proto/service.proto --go_out gen
6163
with-watch sed -i.bak -e 's/old/new/' config.txt
6264
with-watch exec --input 'src/**/*.rs' -- cargo test -p with-watch
6365
```
@@ -66,6 +68,8 @@ with-watch exec --input 'src/**/*.rs' -- cargo test -p with-watch
6668

6769
- Passthrough and shell modes use built-in command adapters before falling back to conservative path heuristics.
6870
- Known outputs, inline scripts, patterns, and shell output redirects are filtered out of the watch set.
71+
- Search adapters such as `rg`, `ag`, and `fd` watch explicit search roots and file-valued pattern/ignore inputs without treating patterns, globs, or type filters as watched paths.
72+
- Schema/codegen adapters such as `protoc`, `flatc`, `thrift`, and `capnp compile` watch source files plus include/import roots while filtering output directories and generated artifacts.
6973
- Pathless defaults are intentionally narrow: only `ls`, `dir`, `vdir`, `du`, and `find` implicitly watch the current directory.
7074
- `ls`-style commands watch directory listings via metadata snapshots: plain `ls` watches immediate children, `ls -R` stays recursive, and `ls -d` watches only the named path.
7175
- `exec --input` remains the explicit escape hatch when a delegated command has no meaningful filesystem inputs or when fallback inference would be ambiguous.
@@ -82,10 +86,10 @@ Dedicated built-in adapters and aliases:
8286

8387
- `cp`, `mv`, `install`, `ln`, `link`, `rm`, `unlink`, `rmdir`, `shred`
8488
- `sort`, `uniq`, `split`, `csplit`, `tee`
85-
- `grep`, `egrep`, `fgrep`, `sed`
89+
- `grep`, `egrep`, `fgrep`, `rg`, `ag`, `sed`
8690
- `awk`, `gawk`, `mawk`, `nawk`
87-
- `find`, `xargs`, `tar`, `touch`, `truncate`
88-
- `chmod`, `chown`, `chgrp`, `dd`
91+
- `find`, `fd`, `xargs`, `tar`, `touch`, `truncate`
92+
- `chmod`, `chown`, `chgrp`, `dd`, `protoc`, `flatc`, `thrift`, `capnp`
8993

9094
Generic read-path commands:
9195

0 commit comments

Comments
 (0)