Skip to content

Commit 432c8e5

Browse files
committed
Support for multiple watch paths
1 parent 5e75472 commit 432c8e5

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

src/main.rs

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,11 @@ struct ShaderBuilder {
9797
skip_block_layout: bool,
9898
#[arg(long, default_value = "false")]
9999
preserve_bindings: bool,
100-
/// If set, will watch the provided path and recompile on change
100+
/// If set, will watch the provided directory and recompile on change.
101+
///
102+
/// Can be specified multiple times to watch more than one directory.
101103
#[arg(short, long)]
102-
watch_path: Option<String>,
104+
watch_paths: Option<Vec<String>>,
103105
}
104106

105107
impl ShaderBuilder {
@@ -138,7 +140,7 @@ fn main() {
138140
}
139141
println!();
140142

141-
if args.watch_path.is_none() {
143+
if args.watch_paths.is_none() {
142144
return;
143145
};
144146

@@ -151,16 +153,19 @@ fn main() {
151153
let fut_values = async move {
152154
let mut args = args;
153155

154-
let Some(watch_path) = args.watch_path.take() else {
156+
let Some(watch_paths) = args.watch_paths.take() else {
155157
unreachable!();
156158
};
157159

158-
info!("Watching {watch_path:} for changes...");
159160
println!();
160161
{
161-
pool.spawn_ok(async move {
162-
async_watch(watch_path, change_tx).await.unwrap();
163-
});
162+
for path in watch_paths {
163+
info!("Watching {path:} for changes...");
164+
let change_tx = change_tx.clone();
165+
pool.spawn_ok(async move {
166+
async_watch(path, change_tx).await.unwrap();
167+
});
168+
}
164169
}
165170

166171
loop {

0 commit comments

Comments
 (0)