Logo Watchexec

$> watchexec make $> watchexec "date >> ../changes.log" $> watchexec --restart --exts js,mjs -- node server.js

Run a command when files in the current directory change. Kick off build processes, restart development servers, detect activity… stop pressing Enter ⏎ over and over again and keep on doing!

Logo Cargo Watch

$> cargo watch $> cargo watch -- cargo test $> cargo watch -x clippy -x "test --exact ice_cream"

Build your Rust project. Two words to get going, more opportunities at your fingertips. Fit for Cargo, fit for life. Your code is in good hands. Oxidise it!

Logo Watchexec library

Create your own watching tool. From presenting different options, to changing the defaults, to responding differently than running commands, to answering to other events. Power your craft!

  1. use watchexec::{
  2. config::ConfigBuilder,
  3. error::Result,
  4. pathop::PathOp,
  5. run::{
  6. ExecHandler,
  7. Handler,
  8. watch,
  9. },
  10. };
  11. fn main() -> Result<()> {
  12. let config = ConfigBuilder::default()
  13. .clear_screen(true)
  14. .run_initially(true)
  15. .paths(vec!["/path/to/dir".into()])
  16. .cmd(vec!["date; seq 1 10".into()])
  17. .build()?;
  18. let handler = MyHandler(ExecHandler::new(config)?);
  19. watch(&handler)
  20. }
  21. struct MyHandler(ExecHandler);
  22. impl Handler for MyHandler {
  23. fn args(&self) -> Config {
  24. self.0.args()
  25. }
  26. fn on_manual(&self) -> Result<bool> {
  27. println!("Running manually!");
  28. self.0.on_manual()
  29. }
  30. fn on_update(&self, ops: &[PathOp]) -> Result<bool> {
  31. println!("Running on update of: {:?}", ops);
  32. self.0.on_update(ops)
  33. }
  34. }

Logo ClearScreen

clearscreen::clear().unwrap();

Clear the terminal. On all platforms, across all terminals. Go beyond \x1b[H\x1b[2J\x1b[3J and start doing the right thing in the right place. Reset even the most dire of states. Erase the past!

Logo Command Group

  1. use std::process::Command;
  2. use command_group::CommandGroup;
  3. let mut child = Command::new("watch").arg("ls").group_spawn()?;
  4. let status = child.wait()?;
  5. dbg!(status);

Run commands in process groups. Stop creating zombies. Avoid unwanted detachment. Regain control!