Implement Outcome::Wait, and CLI on-busy=queue
This commit is contained in:
parent
b923638cbd
commit
645ab74c62
|
@ -100,8 +100,7 @@ fn runtime(args: &ArgMatches<'static>) -> Result<RuntimeConfig> {
|
|||
}
|
||||
|
||||
if once {
|
||||
// TODO
|
||||
// action.outcome(Outcome::both(Outcome::Start, Outcome::both(Outcome::Wait, Outcome::Exit));
|
||||
action.outcome(Outcome::both(Outcome::Start, Outcome::wait(Outcome::Exit)));
|
||||
return fut;
|
||||
}
|
||||
|
||||
|
@ -165,8 +164,8 @@ fn runtime(args: &ArgMatches<'static>) -> Result<RuntimeConfig> {
|
|||
}
|
||||
(false, "restart") => Outcome::both(Outcome::Stop, Outcome::Start),
|
||||
(_, "signal") => Outcome::Signal(signal),
|
||||
// (true, "queue") => Outcome::wait(Outcome::both(Outcome::Clear, Outcome::Start)),
|
||||
// (false, "queue") => Outcome::wait(Outcome::Start),
|
||||
(true, "queue") => Outcome::wait(Outcome::both(Outcome::Clear, Outcome::Start)),
|
||||
(false, "queue") => Outcome::wait(Outcome::Start),
|
||||
_ => Outcome::DoNothing,
|
||||
};
|
||||
|
||||
|
|
|
@ -148,9 +148,9 @@ pub enum Outcome {
|
|||
/// If the command isn't running, start it.
|
||||
Start,
|
||||
|
||||
// TODO
|
||||
// /// Wait for command completion, then start a new one.
|
||||
// Queue,
|
||||
/// Wait for command completion.
|
||||
Wait,
|
||||
|
||||
/// Send this signal to the command.
|
||||
Signal(Signal),
|
||||
|
||||
|
@ -182,6 +182,10 @@ impl Outcome {
|
|||
Self::Both(Box::new(one), Box::new(two))
|
||||
}
|
||||
|
||||
pub fn wait(and_then: Outcome) -> Self {
|
||||
Self::Both(Box::new(Outcome::Wait), Box::new(and_then))
|
||||
}
|
||||
|
||||
fn resolve(self, is_running: bool) -> Self {
|
||||
match (is_running, self) {
|
||||
(true, Self::IfRunning(then, _)) => then.resolve(true),
|
||||
|
@ -379,6 +383,10 @@ async fn apply_outcome(
|
|||
p.signal(sig).await;
|
||||
}
|
||||
|
||||
(Some(p), Outcome::Wait) => {
|
||||
p.wait().await?;
|
||||
}
|
||||
|
||||
(_, Outcome::Clear) => {
|
||||
clearscreen::clear()?;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue