Formatting

This commit is contained in:
Félix Saparelli 2021-04-11 04:32:58 +12:00
parent cdd8a7b91a
commit 5753e7773f
No known key found for this signature in database
GPG Key ID: B948C4BAE44FC474
5 changed files with 29 additions and 21 deletions

View File

@ -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

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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)?;