mirror of
https://github.com/watchexec/watchexec.git
synced 2024-11-16 00:58:31 +01:00
wip
This commit is contained in:
parent
885151261b
commit
48bcf237af
4 changed files with 37 additions and 9 deletions
15
check-hashes.jaq
Normal file
15
check-hashes.jaq
Normal file
|
@ -0,0 +1,15 @@
|
|||
# vim: ft=jq
|
||||
|
||||
def has_changed:
|
||||
. as $file |
|
||||
file_hash |
|
||||
{ prev: kv_fetch($file), cur: (. | kv_store($file)) } |
|
||||
.prev != .cur
|
||||
;
|
||||
|
||||
if any(.tags[]; .kind == "path") then
|
||||
any(
|
||||
.tags[] | select((.kind == "path") and (.filetype == "file"));
|
||||
.absolute | has_changed
|
||||
)
|
||||
else true end
|
|
@ -9,6 +9,8 @@ use clap::{
|
|||
builder::TypedValueParser, error::ErrorKind, Arg, ArgAction, Command, CommandFactory, Parser,
|
||||
ValueEnum, ValueHint,
|
||||
};
|
||||
use miette::{IntoDiagnostic, Result};
|
||||
use tokio::{fs::File, io::AsyncReadExt};
|
||||
use watchexec::paths::PATH_SEPARATOR;
|
||||
use watchexec_signals::Signal;
|
||||
|
||||
|
@ -1153,8 +1155,8 @@ fn expand_args_up_to_doubledash() -> Result<Vec<OsString>, std::io::Error> {
|
|||
}
|
||||
|
||||
#[inline]
|
||||
pub fn get_args() -> Args {
|
||||
use tracing::{debug, warn};
|
||||
pub async fn get_args() -> Result<Args> {
|
||||
use tracing::{debug, trace, warn};
|
||||
|
||||
if std::env::var("RUST_LOG").is_ok() {
|
||||
warn!("⚠ RUST_LOG environment variable set, logging options have no effect");
|
||||
|
@ -1224,6 +1226,18 @@ pub fn get_args() -> Args {
|
|||
.exit();
|
||||
}
|
||||
|
||||
for (n, prog) in args.filter_programs.iter_mut().enumerate() {
|
||||
if let Some(progpath) = prog.strip_prefix('@') {
|
||||
trace!(?n, path=?progpath, "reading filter program from file");
|
||||
let mut progfile = File::open(&progpath).await.into_diagnostic()?;
|
||||
let mut buf =
|
||||
String::with_capacity(progfile.metadata().await.into_diagnostic()?.len() as _);
|
||||
let bytes_read = progfile.read_to_string(&mut buf).await.into_diagnostic()?;
|
||||
debug!(?n, path=?progpath, %bytes_read, "read filter program from file");
|
||||
*prog = buf;
|
||||
}
|
||||
}
|
||||
|
||||
debug!(?args, "got arguments");
|
||||
args
|
||||
Ok(args)
|
||||
}
|
||||
|
|
|
@ -67,7 +67,9 @@ impl FilterProgs {
|
|||
pub fn new(args: &Args) -> miette::Result<Self> {
|
||||
let n_filters = args.filter_programs.len();
|
||||
let progs = args.filter_programs.clone();
|
||||
warn!("EXPERIMENTAL: filter programs are unstable and may change/vanish without notice");
|
||||
eprintln!(
|
||||
"EXPERIMENTAL: filter programs are unstable and may change/vanish without notice"
|
||||
);
|
||||
|
||||
let (requester, mut receiver) = Requester::<Event, bool>::new(BUFFER);
|
||||
let task =
|
||||
|
@ -87,10 +89,7 @@ impl FilterProgs {
|
|||
let name = format!("__watchexec_filter_{n}");
|
||||
let filter = Filter::Call(name, Vec::new());
|
||||
let mut errs = Vec::new();
|
||||
let filter = defs.clone().finish(
|
||||
(Vec::new(), (filter, 0..0)),
|
||||
&mut errs,
|
||||
);
|
||||
let filter = defs.clone().finish((Vec::new(), (filter, 0..0)), &mut errs);
|
||||
if !errs.is_empty() {
|
||||
error!(?errs, "failed to load filter program #{}", n);
|
||||
continue;
|
||||
|
|
|
@ -46,7 +46,7 @@ async fn init() -> Result<Args> {
|
|||
}
|
||||
}
|
||||
|
||||
let args = args::get_args();
|
||||
let args = args::get_args().await?;
|
||||
let verbosity = args.verbose.unwrap_or(0);
|
||||
|
||||
if log_on {
|
||||
|
|
Loading…
Reference in a new issue