watch¶
Watch files and execute a command on change.
Synopsis¶
Description¶
Monitor files for changes and automatically execute a command when changes are detected. Supports recursive watching, file pattern filtering, and automatic process restart.
Flags¶
| Flag | Short | Description | Default |
|---|---|---|---|
--execute |
-e |
Command to execute when files change | (required) |
--patterns |
-p |
File patterns to watch (watches all if not specified) | |
--pattern-type |
Pattern type: regex, literal, glob |
glob |
|
--recursive |
-r |
Watch directories recursively | true |
--include-hidden |
Include hidden files and directories | false |
|
--exclude |
Patterns to exclude (glob style) | ||
--previous-process |
Action for previous process: kill, wait |
kill |
|
--handle-shutdown |
Action when process exits: restart, ignore |
ignore |
|
--restart-policy |
Restart policy: exponential-backoff |
exponential-backoff |
|
--min-backoff-millis |
Minimum backoff in milliseconds | 1000 |
|
--max-backoff-millis |
Maximum backoff in milliseconds | 10000 |
|
--max-restarts |
Maximum automatic restarts | 10 |
Examples¶
Watch current directory and run tests:
Watch specific directory:
Watch only Go files:
Watch with multiple patterns:
Exclude directories:
Use regex patterns:
Auto-restart on crash:
Wait for previous process before restart:
Include hidden files: