console: piped lines run in order; cargo-valid: empty_world allows the first folder of the package path
The runner mounts the package at its host path, so / shows its first folder: tmp locally, build in the Nix sandbox.
This commit is contained in:
+6
-5
@@ -329,7 +329,7 @@ pub async fn run_input(host: Host) -> Result<()> {
|
||||
}
|
||||
});
|
||||
let mut printer = started.await??;
|
||||
run_commands(host, lines, move |text| {
|
||||
run_commands(host, lines, true, move |text| {
|
||||
printer.print(format!("{text}\n"))?;
|
||||
Ok(())
|
||||
})
|
||||
@@ -348,7 +348,7 @@ async fn run_plain(host: Host) -> Result<()> {
|
||||
}
|
||||
}
|
||||
});
|
||||
run_commands(host, lines, |text| {
|
||||
run_commands(host, lines, false, |text| {
|
||||
use std::io::Write;
|
||||
writeln!(std::io::stdout(), "{text}")?;
|
||||
Ok(())
|
||||
@@ -356,10 +356,11 @@ async fn run_plain(host: Host) -> Result<()> {
|
||||
.await
|
||||
}
|
||||
|
||||
// Both input modes keep the prompt available and label asynchronous results.
|
||||
// Both input modes label results. Only terminal input starts concurrent commands.
|
||||
async fn run_commands(
|
||||
host: Host,
|
||||
mut lines: tokio::sync::mpsc::UnboundedReceiver<Result<String>>,
|
||||
concurrent: bool,
|
||||
mut print: impl FnMut(String) -> Result<()>,
|
||||
) -> Result<()> {
|
||||
let mut notifications = host.subscribe();
|
||||
@@ -381,7 +382,7 @@ async fn run_commands(
|
||||
let text = result.unwrap_or_else(|error|format!("error: {error}"));
|
||||
if !text.is_empty() { print(format!("> {line}\n{}",indent(&text)))?; }
|
||||
},
|
||||
line = lines.recv(), if input_open => match line {
|
||||
line = lines.recv(), if input_open && (concurrent || commands.is_empty()) => match line {
|
||||
Some(line) => {
|
||||
let line = line?;
|
||||
if line.trim()=="quit" { print("> quit\n Goodbye.".into())?; return Ok(()); }
|
||||
@@ -446,7 +447,7 @@ mod tests {
|
||||
let mut events = host.subscribe();
|
||||
let (sender, lines) = tokio::sync::mpsc::unbounded_channel();
|
||||
let (printed, mut output) = tokio::sync::mpsc::unbounded_channel();
|
||||
let runner = tokio::spawn(run_commands(host.clone(), lines, move |text| {
|
||||
let runner = tokio::spawn(run_commands(host.clone(), lines, true, move |text| {
|
||||
printed.send(text).unwrap();
|
||||
Ok(())
|
||||
}));
|
||||
|
||||
Reference in New Issue
Block a user