mirror of
https://github.com/watchexec/watchexec.git
synced 2024-11-14 08:11:11 +01:00
Formatting
This commit is contained in:
parent
cdd8a7b91a
commit
5753e7773f
5 changed files with 29 additions and 21 deletions
12
src/args.rs
12
src/args.rs
|
@ -1,13 +1,13 @@
|
|||
use clap::{App, Arg, value_t, values_t, crate_version};
|
||||
use clap::{crate_version, value_t, values_t, App, Arg};
|
||||
use log::LevelFilter;
|
||||
use std::{
|
||||
ffi::OsString,
|
||||
path::{PathBuf, MAIN_SEPARATOR},
|
||||
};
|
||||
|
||||
use crate::{error, Shell};
|
||||
use crate::config::{Config, ConfigBuilder};
|
||||
use crate::run::OnBusyUpdate;
|
||||
use crate::{error, Shell};
|
||||
|
||||
pub fn get_args() -> error::Result<(Config, LevelFilter)> {
|
||||
get_args_impl(None::<&[&str]>)
|
||||
|
@ -146,7 +146,8 @@ where
|
|||
|
||||
let mut builder = ConfigBuilder::default();
|
||||
|
||||
let cmd: Vec<String> = values_t!(args.values_of("command"), String).map_err(|err| err.to_string())?;
|
||||
let cmd: Vec<String> =
|
||||
values_t!(args.values_of("command"), String).map_err(|err| err.to_string())?;
|
||||
builder.cmd(cmd);
|
||||
|
||||
let paths: Vec<PathBuf> = values_t!(args.values_of("path"), String)
|
||||
|
@ -167,7 +168,8 @@ where
|
|||
|
||||
let mut filters = values_t!(args.values_of("filter"), String).unwrap_or_else(|_| Vec::new());
|
||||
if let Some(extensions) = args.values_of("extensions") {
|
||||
for exts in extensions { // TODO: refactor with flatten()
|
||||
for exts in extensions {
|
||||
// TODO: refactor with flatten()
|
||||
filters.extend(exts.split(',').filter_map(|ext| {
|
||||
if ext.is_empty() {
|
||||
None
|
||||
|
@ -219,7 +221,7 @@ where
|
|||
b"queue" => OnBusyUpdate::Queue,
|
||||
b"restart" => OnBusyUpdate::Restart,
|
||||
b"signal" => OnBusyUpdate::Signal,
|
||||
_ => unreachable!("clap restricts on-busy-updates values")
|
||||
_ => unreachable!("clap restricts on-busy-updates values"),
|
||||
}
|
||||
} else {
|
||||
// will become DoNothing in v2.0
|
||||
|
|
19
src/cli.rs
19
src/cli.rs
|
@ -7,13 +7,16 @@ use crate::config::{Config, ConfigBuilder};
|
|||
#[deprecated(since = "1.15.0", note = "Config has moved to config::Config")]
|
||||
pub type Args = Config;
|
||||
|
||||
#[deprecated(since = "1.15.0", note = "ConfigBuilder has moved to config::ConfigBuilder")]
|
||||
#[deprecated(
|
||||
since = "1.15.0",
|
||||
note = "ConfigBuilder has moved to config::ConfigBuilder"
|
||||
)]
|
||||
pub type ArgsBuilder = ConfigBuilder;
|
||||
|
||||
/// Clear the screen.
|
||||
#[cfg(target_family = "windows")]
|
||||
pub fn clear_screen() {
|
||||
// TODO: clearscreen with powershell?
|
||||
// TODO: clearscreen with powershell?
|
||||
let _ = Command::new("cmd")
|
||||
.arg("/c")
|
||||
.arg("tput reset || cls")
|
||||
|
@ -23,12 +26,18 @@ pub fn clear_screen() {
|
|||
/// Clear the screen.
|
||||
#[cfg(target_family = "unix")]
|
||||
pub fn clear_screen() {
|
||||
// TODO: clear screen via control codes instead
|
||||
// TODO: clear screen via control codes instead
|
||||
let _ = Command::new("tput").arg("reset").status();
|
||||
}
|
||||
|
||||
#[deprecated(since = "1.15.0", note = "this will be removed from the library API. use the builder")]
|
||||
#[deprecated(
|
||||
since = "1.15.0",
|
||||
note = "this will be removed from the library API. use the builder"
|
||||
)]
|
||||
pub use crate::args::get_args;
|
||||
|
||||
#[deprecated(since = "1.15.0", note = "this will be removed from the library API. use the builder")]
|
||||
#[deprecated(
|
||||
since = "1.15.0",
|
||||
note = "this will be removed from the library API. use the builder"
|
||||
)]
|
||||
pub use crate::args::get_args_from;
|
||||
|
|
10
src/lib.rs
10
src/lib.rs
|
@ -9,10 +9,7 @@
|
|||
//!
|
||||
//! [watchexec]: https://github.com/watchexec/watchexec
|
||||
|
||||
#![warn(
|
||||
clippy::option_unwrap_used,
|
||||
clippy::result_unwrap_used,
|
||||
)]
|
||||
#![warn(clippy::option_unwrap_used, clippy::result_unwrap_used)]
|
||||
|
||||
#[macro_use]
|
||||
extern crate derive_builder;
|
||||
|
@ -40,5 +37,8 @@ pub use run::{run, watch, Handler};
|
|||
#[deprecated(since = "1.15.0", note = "Config has moved to config::Config")]
|
||||
pub type Args = config::Config;
|
||||
|
||||
#[deprecated(since = "1.15.0", note = "ConfigBuilder has moved to config::ConfigBuilder")]
|
||||
#[deprecated(
|
||||
since = "1.15.0",
|
||||
note = "ConfigBuilder has moved to config::ConfigBuilder"
|
||||
)]
|
||||
pub type ArgsBuilder = config::ConfigBuilder;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use std::io::Write;
|
||||
|
||||
// until args.rs is removed from the lib
|
||||
pub(crate) use watchexec::{error, config, run, Shell};
|
||||
pub(crate) use watchexec::{config, error, run, Shell};
|
||||
|
||||
mod args;
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use crate::cli::{clear_screen};
|
||||
use crate::cli::clear_screen;
|
||||
use crate::config::Config;
|
||||
use crate::error::{Error, Result};
|
||||
use crate::gitignore;
|
||||
|
@ -231,10 +231,7 @@ impl Handler for ExecHandler {
|
|||
fn on_update(&self, ops: &[PathOp]) -> Result<bool> {
|
||||
let signal = self.signal.unwrap_or(Signal::SIGTERM);
|
||||
|
||||
match (
|
||||
self.has_running_process(),
|
||||
self.args.on_busy_update,
|
||||
) {
|
||||
match (self.has_running_process(), self.args.on_busy_update) {
|
||||
// If nothing is running, start the command
|
||||
(false, _) => {
|
||||
self.spawn(ops)?;
|
||||
|
|
Loading…
Reference in a new issue