Skip to content

Commit

Permalink
Autowatch (--watch) (#14)
Browse files Browse the repository at this point in the history
* Fix deprecation warning from winnow

* Add dependency and CLI args

* Re-fix Cargo.lock

* Implement --watch

* Book chapter

* Change terminology to avoid confusion

* Update CLI reference
  • Loading branch information
simonask authored Jan 21, 2025
1 parent e33ce9c commit dd23516
Show file tree
Hide file tree
Showing 25 changed files with 617 additions and 105 deletions.
174 changes: 171 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ regex = "1.11.1"
serde = { version = "1.0.215", features = ["derive"] }
smol = "2.0.2"
toml_edit = "0.22.22"
futures = "0.3.31"

[workspace.lints.clippy]
pedantic = { level = "warn", priority = -1 }
Expand Down
4 changes: 2 additions & 2 deletions TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
- [ ] Forward doc comments from TOML to `--list`.
- [ ] Autoclean: Match files in the output directory against available recipes
and delete them if they are older than `.werk-cache`.
- [ ] Autowatcher: Run a recipe and detect which files where checked for
outdatedness, and then watch those files and rebuild when any of them changes.

## Done

- [x] Autowatcher: Run a recipe and detect which files where checked for
outdatedness, and then watch those files and rebuild when any of them changes.
- [x] Don't use `RUST_LOG` to enable logging, as it interferes with child
processes. ~~Use `WERK_LOG` instead.~~
- [x] Support generating depfiles in the same command that compiles the file.
Expand Down
1 change: 1 addition & 0 deletions book/src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
- [When is a target outdated?](./outdatedness.md)
- [Depfile support](./depfile_support.md)
- [Configure your build](./build_config.md)
- [Watch for changes](./watch.md)

# Reference Guide

Expand Down
32 changes: 22 additions & 10 deletions book/src/command_line.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ Arguments:
Options:
-f, --file <FILE>
The path to the Werkfile. Defaults to searching for `Werkfile` in the current
working directory and its parents
The path to the Werkfile. Defaults to searching for `Werkfile` in the
current working directory and its parents
-l, --list
List the available recipes
Expand All @@ -27,28 +27,40 @@ Options:
--print-fresh
Print recipes that were up-to-date. Implied by `--verbose`
--no-capture
Forward the stdout of all executed commands to the terminal, even when
successful. Stderr output is always forwarded. Implied by `--verbose`
--quiet
Silence informational output from executed commands, only printing to
the terminal when a recipe fails
--loud
Print all informational output from executed commands to the terminal,
even for quiet recipes. Implied by `--verbose`
--explain
For each outdated target, explain why it was outdated. Implied by `--verbose`
-v, --verbose
Shorthand for `--explain --print-commands --print-fresh --no-capture`
Shorthand for `--explain --print-commands --print-fresh --no-capture --loud`
-w, --watch
Build the target, then keep rebuilding it when the workspace changes
--watch-delay <WATCH_DELAY>
Number of milliseconds to wait after a filesystem change before
rebuilding. Implies `--watch`
[default: 250]
--color <COLOR>
[default: auto]
Possible values:
- auto: Probe the current terminal and environment variables for color
support
- always: Force color output, even if the command is not running in a
terminal
- always: Force color output, even if the command is not running in a terminal
- never: Do not use color output
--output-format <OUTPUT_FORMAT>
[default: auto]
[default: ansi]
Possible values:
- ansi: Provide friendly user feedback assuming an ANSI terminal
Expand All @@ -67,7 +79,7 @@ Options:
Use the output directory instead of the default
-D, --define <DEFINE>
Override global variable. This takes the form `name=value`.
Override global variable. This takes the form `name=value`
--log [<LOG>]
Enable debug logging to stdout.
Expand Down
6 changes: 6 additions & 0 deletions book/src/examples/c.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,10 @@ task build {
build "my-program{EXE_SUFFIX}"
info "Build complete!"
}
task run {
let executable = "my-program{EXE_SUFFIX}"
build executable
run "<executable>"
}
```
Loading

0 comments on commit dd23516

Please sign in to comment.