mirror of
https://github.com/zaphar/runwhen.git
synced 2025-07-26 21:19:50 -04:00
Compare commits
1 Commits
Author | SHA1 | Date | |
---|---|---|---|
b69af94e5a |
2
Cargo.lock
generated
2
Cargo.lock
generated
@ -301,7 +301,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "runwhen"
|
name = "runwhen"
|
||||||
version = "0.0.8"
|
version = "0.0.7"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"clap",
|
"clap",
|
||||||
"glob",
|
"glob",
|
||||||
|
12
src/main.rs
12
src/main.rs
@ -14,9 +14,9 @@
|
|||||||
// runwhen - A utility that runs commands on user defined triggers.
|
// runwhen - A utility that runs commands on user defined triggers.
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate clap;
|
extern crate clap;
|
||||||
extern crate glob;
|
|
||||||
extern crate humantime;
|
extern crate humantime;
|
||||||
extern crate notify;
|
extern crate notify;
|
||||||
|
extern crate glob;
|
||||||
|
|
||||||
use std::{process, str::FromStr};
|
use std::{process, str::FromStr};
|
||||||
|
|
||||||
@ -45,11 +45,11 @@ fn do_flags() -> clap::ArgMatches {
|
|||||||
clap::Command::new("watch")
|
clap::Command::new("watch")
|
||||||
.about("Trigger that fires when a file or directory changes.")
|
.about("Trigger that fires when a file or directory changes.")
|
||||||
.arg(
|
.arg(
|
||||||
arg!(-f --file ...).name("file")
|
arg!(-f --file).name("file")
|
||||||
.takes_value(true).help("File or directory to watch for changes"),
|
.takes_value(true).help("File or directory to watch for changes"),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
arg!(-e --exclude ...).name("exclude")
|
arg!(-e --exclude).name("exclude")
|
||||||
.takes_value(true).help("path names to skip when watching. Specified in unix glob format."),
|
.takes_value(true).help("path names to skip when watching. Specified in unix glob format."),
|
||||||
)
|
)
|
||||||
.arg(arg!(--touch).name("filetouch").help("Use file or directory timestamps to monitor for changes."))
|
.arg(arg!(--touch).name("filetouch").help("Use file or directory timestamps to monitor for changes."))
|
||||||
@ -58,7 +58,7 @@ fn do_flags() -> clap::ArgMatches {
|
|||||||
clap::Command::new("timer")
|
clap::Command::new("timer")
|
||||||
.about("Run command on a timer")
|
.about("Run command on a timer")
|
||||||
.arg(arg!(-t --duration).takes_value(true).value_parser(value_parser!(humantime::Duration)).help("Duration between runs"))
|
.arg(arg!(-t --duration).takes_value(true).value_parser(value_parser!(humantime::Duration)).help("Duration between runs"))
|
||||||
.arg(arg!(-n --repeat).value_parser(value_parser!(u32)).help("Number of times to run before finishing")))
|
.arg(arg!(-n --repeat).value_parser(value_parser!(u32))).about("Number of times to run before finishing"))
|
||||||
.subcommand(
|
.subcommand(
|
||||||
clap::Command::new("success")
|
clap::Command::new("success")
|
||||||
.about("Run a command when a test command succeeds")
|
.about("Run a command when a test command succeeds")
|
||||||
@ -100,9 +100,7 @@ fn main() {
|
|||||||
None => None,
|
None => None,
|
||||||
};
|
};
|
||||||
println!("Enforcing a poll time of {:?}", duration);
|
println!("Enforcing a poll time of {:?}", duration);
|
||||||
Box::new(FileProcess::new(
|
Box::new(FileProcess::new(cmd, maybe_env, file, exclude, method, duration))
|
||||||
cmd, maybe_env, file, exclude, method, duration,
|
|
||||||
))
|
|
||||||
} else if let Some(matches) = app.subcommand_matches("timer") {
|
} else if let Some(matches) = app.subcommand_matches("timer") {
|
||||||
// TODO(jwall): This should use cancelable commands.
|
// TODO(jwall): This should use cancelable commands.
|
||||||
// Unwrap because this flag is required.
|
// Unwrap because this flag is required.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user