Skip to content
Snippets Groups Projects
Commit e4f9ccf5 authored by Simon Sapin's avatar Simon Sapin
Browse files

Hide script output by default

… with a CLI option to opt out
parent 32945e71
No related branches found
No related tags found
1 merge request!1Initial implementation
......@@ -17,6 +17,10 @@
/// The script to run in each dataset. Passed to /bin/sh
script: String,
/// Pass through the script’s stdout and stderr
#[structopt(long)]
script_output: bool,
}
pub(crate) fn run(megafine: &Megafine, args: &Args) -> Result<()> {
......@@ -36,7 +40,6 @@
let zstd = zstd::Decoder::new(archive_file)?;
tar::Archive::new(zstd).unpack(tmp.path())?;
println!("Running in {}", style(&dataset.name).bold());
let mut command = process::Command::new("sh");
command
.arg("-c")
......@@ -44,6 +47,15 @@
.current_dir(tmp.path())
.env("HGRCPATH", "")
.env("PAGER", "");
print!("Running in {}", style(&dataset.name).bold());
if args.script_output {
println!();
} else {
print!("… ");
command
.stdout(process::Stdio::null())
.stderr(process::Stdio::null());
}
let start = Instant::now();
let status = command.status()?;
let ms = (start.elapsed().as_secs_f64() * 1000.) as u32;
......@@ -47,6 +59,10 @@
let start = Instant::now();
let status = command.status()?;
let ms = (start.elapsed().as_secs_f64() * 1000.) as u32;
if args.script_output {
print!("Duration: ")
}
println!("{} ms", style(ms).bold());
if !status.success() {
if let Some(code) = status.code() {
eprintln!(
......@@ -57,7 +73,6 @@
eprintln!("{}", style("Script failed").red())
}
}
println!("Duration: {} ms", style(ms).bold());
tmp.close()?;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment