Remove --watch option, always watch cwd

This commit is contained in:
Matt Green 2016-11-15 09:27:53 -05:00
parent 0e9dafffc8
commit f768721ca3
2 changed files with 3 additions and 20 deletions

View File

@ -6,7 +6,6 @@ use clap::{App, Arg};
#[derive(Debug)]
pub struct Args {
pub cmd: String,
pub paths: Vec<String>,
pub filters: Vec<String>,
pub ignores: Vec<String>,
pub clear_screen: bool,
@ -34,13 +33,6 @@ pub fn get_args() -> Args {
let args = App::new("watchexec")
.version(crate_version!())
.about("Execute commands when watched files change")
.arg(Arg::with_name("path")
.help("Path to watch [default: .]")
.short("w")
.long("watch")
.number_of_values(1)
.multiple(true)
.takes_value(true))
.arg(Arg::with_name("command")
.help("Command to execute")
.multiple(true)
@ -92,7 +84,6 @@ pub fn get_args() -> Args {
.get_matches();
let cmd = values_t!(args.values_of("command"), String).unwrap().join(" ");
let paths = values_t!(args.values_of("path"), String).unwrap_or(vec![String::from(".")]);
let mut filters = values_t!(args.values_of("filter"), String).unwrap_or(vec![]);
if let Some(extensions) = args.values_of("extensions") {
@ -121,7 +112,6 @@ pub fn get_args() -> Args {
Args {
cmd: cmd,
paths: paths,
filters: filters,
ignores: ignores,
clear_screen: args.is_present("clear"),

View File

@ -28,10 +28,11 @@ mod watcher;
use std::collections::HashMap;
use std::env;
use std::path::Path;
use std::sync::{Arc, RwLock};
use std::sync::mpsc::{channel, Receiver};
use std::time::Duration;
use std::path::{Path, PathBuf};
use std::path::{PathBuf};
use notification_filter::NotificationFilter;
use process::Process;
@ -119,15 +120,7 @@ fn main() {
warn!("Polling for changes every {} ms", args.poll_interval);
}
for path in args.paths {
match Path::new(&path).canonicalize() {
Ok(canonicalized) => watcher.watch(canonicalized).expect("unable to watch path"),
Err(_) => {
println!("invalid path: {}", path);
return;
}
}
}
watcher.watch(cwd).expect("unable to watch cwd");
// Start child process initially, if necessary
if args.run_initially {