1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
//! Watchexec: a library for utilities and programs which respond to (file, signal, etc) events
//! primarily by launching or managing other programs.
//!
//! Also see the CLI tool: <https://github.com/watchexec/watchexec>
//!
//! This library is powered by [Tokio](https://tokio.rs).
//!
//! The main way to use this crate involves constructing a [`Watchexec`] around a [`Config`], then
//! running it. Handlers (defined in [`Config`]) are used to hook into Watchexec at various points.
//! The config can be changed at any time with the `config` field on your [`Watchexec`] instance.
//!
//! It's recommended to use the [miette] erroring library in applications, but all errors implement
//! [`std::error::Error`] so your favourite error handling library can of course be used.
//!
//! ```no_run
//! use miette::{IntoDiagnostic, Result};
//! use watchexec_signals::Signal;
//! use watchexec::Watchexec;
//!
//! #[tokio::main]
//! async fn main() -> Result<()> {
//! let wx = Watchexec::new(|mut action| {
//! // print any events
//! for event in action.events.iter() {
//! eprintln!("EVENT: {event:?}");
//! }
//!
//! // if Ctrl-C is received, quit
//! if action.signals().any(|sig| sig == Signal::Interrupt) {
//! action.quit();
//! }
//!
//! action
//! })?;
//!
//! // watch the current directory
//! wx.config.pathset(["."]);
//!
//! wx.main().await.into_diagnostic()?;
//! Ok(())
//! }
//! ```
//!
//! Alternatively, you can use the modules exposed by the crate and the external crates such as
//! [`notify`], [`clearscreen`](https://docs.rs/clearscreen), [`process_wrap`]... to build something
//! more advanced, at the cost of reimplementing the glue code.
//!
//! Note that the library generates a _lot_ of debug messaging with [tracing]. **You should not
//! enable printing even `error`-level log messages for this crate unless it's for debugging.**
//! Instead, make use of the [`Config::on_error()`] method to define a handler for errors
//! occurring at runtime that are _meant_ for you to handle (by printing out or otherwise).
// the toolkit to make your own
// the core experience
pub use crate::;
pub use crateConfig;
pub use ;