Struct Watch

Source
#[non_exhaustive]
pub struct Watch { pub shell_commands: Vec<String>, pub cargo_commands: Vec<String>, pub watch_paths: Vec<PathBuf>, pub exclude_paths: Vec<PathBuf>, pub workspace_exclude_paths: Vec<PathBuf>, pub debounce: Duration, }
Expand description

Watches over your project’s source code, relaunching a given command when changes are detected.

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§shell_commands: Vec<String>

Shell command(s) to execute on changes.

§cargo_commands: Vec<String>

Cargo command(s) to execute on changes.

The default is [ check ]

§watch_paths: Vec<PathBuf>

Watch specific file(s) or folder(s).

The default is the workspace root.

§exclude_paths: Vec<PathBuf>

Paths that will be excluded.

§workspace_exclude_paths: Vec<PathBuf>

Paths, relative to the workspace root, that will be excluded.

§debounce: Duration

Throttle events to prevent the command to be re-executed too early right after an execution already occurred.

The default is 2 seconds.

Implementations§

Source§

impl Watch

Source

pub fn watch_path(self, path: impl AsRef<Path>) -> Self

Add a path to watch for changes.

Source

pub fn watch_paths( self, paths: impl IntoIterator<Item = impl AsRef<Path>>, ) -> Self

Add multiple paths to watch for changes.

Source

pub fn exclude_path(self, path: impl AsRef<Path>) -> Self

Add a path that will be ignored if changes are detected.

Source

pub fn exclude_paths( self, paths: impl IntoIterator<Item = impl AsRef<Path>>, ) -> Self

Add multiple paths that will be ignored if changes are detected.

Source

pub fn exclude_workspace_path(self, path: impl AsRef<Path>) -> Self

Add a path, relative to the workspace, that will be ignored if changes are detected.

Source

pub fn exclude_workspace_paths( self, paths: impl IntoIterator<Item = impl AsRef<Path>>, ) -> Self

Add multiple paths, relative to the workspace, that will be ignored if changes are detected.

Source

pub fn debounce(self, duration: Duration) -> Self

Set the debounce duration after relaunching the command.

Source

pub fn run(self, commands: impl Into<CommandList>) -> Result<()>

Run the given command, monitor the watched paths and relaunch the command when changes are detected.

Workspace’s target directory and hidden paths are excluded by default.

Trait Implementations§

Source§

impl Args for Watch

Source§

fn group_id() -> Option<Id>

Report the ArgGroup::id for this set of arguments
Source§

fn augment_args<'b>(__clap_app: Command) -> Command

Append to Command so it can instantiate Self via FromArgMatches::from_arg_matches_mut Read more
Source§

fn augment_args_for_update<'b>(__clap_app: Command) -> Command

Append to Command so it can instantiate self via FromArgMatches::update_from_arg_matches_mut Read more
Source§

impl Clone for Watch

Source§

fn clone(&self) -> Watch

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl CommandFactory for Watch

Source§

fn command<'b>() -> Command

Build a Command that can instantiate Self. Read more
Source§

fn command_for_update<'b>() -> Command

Build a Command that can update self. Read more
Source§

impl Debug for Watch

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Watch

Source§

fn default() -> Watch

Returns the “default value” for a type. Read more
Source§

impl FromArgMatches for Watch

Source§

fn from_arg_matches(__clap_arg_matches: &ArgMatches) -> Result<Self, Error>

Instantiate Self from ArgMatches, parsing the arguments as needed. Read more
Source§

fn from_arg_matches_mut( __clap_arg_matches: &mut ArgMatches, ) -> Result<Self, Error>

Instantiate Self from ArgMatches, parsing the arguments as needed. Read more
Source§

fn update_from_arg_matches( &mut self, __clap_arg_matches: &ArgMatches, ) -> Result<(), Error>

Assign values from ArgMatches to self.
Source§

fn update_from_arg_matches_mut( &mut self, __clap_arg_matches: &mut ArgMatches, ) -> Result<(), Error>

Assign values from ArgMatches to self.
Source§

impl Parser for Watch

Source§

fn parse() -> Self

Parse from std::env::args_os(), exit on error.
Source§

fn try_parse() -> Result<Self, Error>

Parse from std::env::args_os(), return Err on error.
Source§

fn parse_from<I, T>(itr: I) -> Self
where I: IntoIterator<Item = T>, T: Into<OsString> + Clone,

Parse from iterator, exit on error.
Source§

fn try_parse_from<I, T>(itr: I) -> Result<Self, Error>
where I: IntoIterator<Item = T>, T: Into<OsString> + Clone,

Parse from iterator, return Err on error.
Source§

fn update_from<I, T>(&mut self, itr: I)
where I: IntoIterator<Item = T>, T: Into<OsString> + Clone,

Update from iterator, exit on error. Read more
Source§

fn try_update_from<I, T>(&mut self, itr: I) -> Result<(), Error>
where I: IntoIterator<Item = T>, T: Into<OsString> + Clone,

Update from iterator, return Err on error.

Auto Trait Implementations§

§

impl Freeze for Watch

§

impl RefUnwindSafe for Watch

§

impl Send for Watch

§

impl Sync for Watch

§

impl Unpin for Watch

§

impl UnwindSafe for Watch

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.