Add InitConfig::builder() to be a little more idiomatic
Neat side effect: keeps rust-analyzer from complaining about unknown types (because it doesn't expand the builder macro)!
This commit is contained in:
parent
b4ead7f5fb
commit
05afb141b6
|
@ -1,6 +1,6 @@
|
|||
use watchexec::{
|
||||
action::{Action, Outcome},
|
||||
config::{InitConfigBuilder, RuntimeConfig},
|
||||
config::{InitConfig, RuntimeConfig},
|
||||
error::ReconfigError,
|
||||
fs::Watcher,
|
||||
signal::Signal,
|
||||
|
@ -13,14 +13,14 @@ async fn main() -> color_eyre::eyre::Result<()> {
|
|||
tracing_subscriber::fmt::init();
|
||||
color_eyre::install()?;
|
||||
|
||||
let mut init = InitConfigBuilder::default();
|
||||
let mut init = InitConfig::builder();
|
||||
init.on_error(|err| async move {
|
||||
eprintln!("Watchexec Runtime Error: {}", err);
|
||||
Ok::<(), std::convert::Infallible>(())
|
||||
});
|
||||
|
||||
let mut runtime = RuntimeConfig::default();
|
||||
runtime.pathset(["src"]);
|
||||
runtime.pathset(["src", "dontexist", "examples"]);
|
||||
runtime.command(["date"]);
|
||||
|
||||
let wx = Watchexec::new(init.build()?, runtime.clone())?;
|
||||
|
|
|
@ -139,6 +139,13 @@ pub struct InitConfig {
|
|||
pub event_channel_size: usize,
|
||||
}
|
||||
|
||||
impl InitConfig {
|
||||
/// Returns a new [`InitConfigBuilder`] for builder the initial configuration.
|
||||
pub fn builder() -> InitConfigBuilder {
|
||||
InitConfigBuilder::default()
|
||||
}
|
||||
}
|
||||
|
||||
impl InitConfigBuilder {
|
||||
/// Set the runtime error handler.
|
||||
///
|
||||
|
|
|
@ -17,13 +17,13 @@
|
|||
//! use watchexec::{
|
||||
//! Watchexec,
|
||||
//! action::{Action, Outcome},
|
||||
//! config::{InitConfigBuilder, RuntimeConfig},
|
||||
//! config::{InitConfig, RuntimeConfig},
|
||||
//! handler::{Handler as _, PrintDebug},
|
||||
//! };
|
||||
//!
|
||||
//! #[tokio::main]
|
||||
//! async fn main() -> Result<(), Report> {
|
||||
//! let mut init = InitConfigBuilder::default();
|
||||
//! let mut init = InitConfig::builder();
|
||||
//! init.on_error(PrintDebug(std::io::stderr()));
|
||||
//!
|
||||
//! let mut runtime = RuntimeConfig::default();
|
||||
|
|
|
@ -2,7 +2,7 @@ use std::time::Duration;
|
|||
|
||||
use tokio::time::sleep;
|
||||
use watchexec::{
|
||||
config::{InitConfigBuilder, RuntimeConfig},
|
||||
config::{InitConfig, RuntimeConfig},
|
||||
Watchexec,
|
||||
};
|
||||
|
||||
|
@ -11,7 +11,7 @@ async fn main() -> color_eyre::eyre::Result<()> {
|
|||
tracing_subscriber::fmt::init();
|
||||
color_eyre::install()?;
|
||||
|
||||
let mut init = InitConfigBuilder::default();
|
||||
let mut init = InitConfig::builder();
|
||||
init.on_error(|err| async move {
|
||||
eprintln!("Watchexec Runtime Error: {}", err);
|
||||
Ok::<(), std::convert::Infallible>(())
|
||||
|
|
Loading…
Reference in New Issue