fix(repl): respect --quiet flag (#16875)

This commit changes REPL behavior to respect --quiet flag. Once 
this flag is present REPL will not print a banner at the start.
This commit is contained in:
Bartek Iwańczuk 2022-11-30 23:25:20 +01:00 committed by GitHub
parent 381932ce1e
commit d1962e07af
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 36 additions and 7 deletions

View file

@ -101,11 +101,14 @@ pub async fn run(
.await?;
// only output errors
if let EvaluationOutput::Error(error_text) = output {
println!("error in --eval-file file {}. {}", eval_file, error_text);
println!(
"Error in --eval-file file \"{}\": {}",
eval_file, error_text
);
}
}
Err(e) => {
println!("error in --eval-file file {}. {}", eval_file, e);
println!("Error in --eval-file file \"{}\": {}", eval_file, e);
}
}
}
@ -115,12 +118,16 @@ pub async fn run(
let output = repl_session.evaluate_line_and_get_output(&eval).await?;
// only output errors
if let EvaluationOutput::Error(error_text) = output {
println!("error in --eval flag. {}", error_text);
println!("Error in --eval flag: {}", error_text);
}
}
println!("Deno {}", crate::version::deno());
println!("exit using ctrl+d, ctrl+c, or close()");
// Doing this manually, instead of using `log::info!` because these messages
// are supposed to go to stdout, not stderr.
if !ps.options.is_quiet() {
println!("Deno {}", crate::version::deno());
println!("exit using ctrl+d, ctrl+c, or close()");
}
loop {
let line = read_line_and_poll(