-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allows multiple commands to watch #24
Conversation
src/lib.rs
Outdated
let _ = child.wait(); | ||
let _ = child.kill(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
haha 😁 you actually need to do the opposite. Otherwise you will wait for the child to complete
src/lib.rs
Outdated
@@ -440,6 +427,52 @@ impl EventHandler for WatchEventHandler { | |||
} | |||
} | |||
|
|||
struct ShareableChild(Arc<Mutex<Option<Child>>>); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I would rather call it SharedChild...... not sure why tbh....
src/lib.rs
Outdated
@@ -107,7 +107,7 @@ | |||
//! match opt { | |||
//! Opt::Watch(watch) => { | |||
//! log::info!("Starting to watch `cargo check`"); | |||
//! watch.run(run_command)?; | |||
//! watch.run(vec![run_command])?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent work!
You see how abstracting the logic behind ShareableChild made everything easier.
Now I would like you to improve the API of the fn run()
on this watch object. You see, in the past we could provide a command and it would work. Ideally we want to preserve this behavior AND allow passing an iterable over commands. insert why-not-both.gif here
In order to do that, instead of taking the parameter mut commands: Vec<Command>
you can create a new type and take as parameter mut commands: impl Into<CommandList>
.
I think I have already said too much so I will leave the rest to you. The goal is to allow this:
watch.run(vec![run_command])?;
(list of commands, the easiest)watch.run(run_command)?;
(single command, easy)watch.run(&[run_command])?;
(any iterable actually, you need to get your hand on generic parameters, more complicated, I believe in you)
No description provided.