mirror of
https://github.com/zaphar/runwhen.git
synced 2025-07-22 20:39:49 -04:00
Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
27cf79ffe4 | |||
fb954c6f0d | |||
e980306761 |
2
Cargo.lock
generated
2
Cargo.lock
generated
@ -301,7 +301,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "runwhen"
|
||||
version = "0.0.7"
|
||||
version = "0.0.8"
|
||||
dependencies = [
|
||||
"clap",
|
||||
"glob",
|
||||
|
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "runwhen"
|
||||
version = "0.0.7"
|
||||
version = "0.0.8"
|
||||
authors = ["Jeremy Wall <jeremy@marzhillstudios.com>"]
|
||||
description = "Runs a command on user specified triggers."
|
||||
repository = "https://github.com/zaphar/runwhen"
|
||||
|
@ -19,7 +19,7 @@
|
||||
inherit flake-compat;
|
||||
defaultPackage = naersk-lib.buildPackage rec {
|
||||
pname = "runwhen";
|
||||
version = "0.0.6";
|
||||
version = "0.0.8";
|
||||
src = ./.;
|
||||
cargoBuildOptions = opts: opts ++ ["-p" "${pname}" ];
|
||||
};
|
||||
|
14
src/main.rs
14
src/main.rs
@ -14,9 +14,9 @@
|
||||
// runwhen - A utility that runs commands on user defined triggers.
|
||||
#[macro_use]
|
||||
extern crate clap;
|
||||
extern crate glob;
|
||||
extern crate humantime;
|
||||
extern crate notify;
|
||||
extern crate glob;
|
||||
|
||||
use std::{process, str::FromStr};
|
||||
|
||||
@ -45,11 +45,11 @@ fn do_flags() -> clap::ArgMatches {
|
||||
clap::Command::new("watch")
|
||||
.about("Trigger that fires when a file or directory changes.")
|
||||
.arg(
|
||||
arg!(-f --file).name("file")
|
||||
arg!(-f --file ...).name("file")
|
||||
.takes_value(true).help("File or directory to watch for changes"),
|
||||
)
|
||||
.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."),
|
||||
)
|
||||
.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")
|
||||
.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!(-n --repeat).value_parser(value_parser!(u32))).about("Number of times to run before finishing"))
|
||||
.arg(arg!(-n --repeat).value_parser(value_parser!(u32)).help("Number of times to run before finishing")))
|
||||
.subcommand(
|
||||
clap::Command::new("success")
|
||||
.about("Run a command when a test command succeeds")
|
||||
@ -80,7 +80,7 @@ fn main() {
|
||||
}
|
||||
maybe_env = Some(env_vec);
|
||||
}
|
||||
|
||||
|
||||
let mut proc: Box<dyn Process> = if let Some(matches) = app.subcommand_matches("watch") {
|
||||
let file = match matches.values_of("file") {
|
||||
Some(v) => v.collect(),
|
||||
@ -100,7 +100,9 @@ fn main() {
|
||||
None => None,
|
||||
};
|
||||
println!("Enforcing a poll time of {:?}", duration);
|
||||
Box::new(FileProcess::new(cmd, maybe_env, file, exclude, method, duration))
|
||||
Box::new(FileProcess::new(
|
||||
cmd, maybe_env, file, exclude, method, duration,
|
||||
))
|
||||
} else if let Some(matches) = app.subcommand_matches("timer") {
|
||||
// TODO(jwall): This should use cancelable commands.
|
||||
// Unwrap because this flag is required.
|
||||
|
Loading…
x
Reference in New Issue
Block a user