Do not crash on empty terminal

This commit is contained in:
Quentin Le Sceller 2019-05-03 11:24:49 -04:00
parent e673fd9f91
commit b76c18d6f1
No known key found for this signature in database
GPG key ID: 8208307D088EA3BA

View file

@ -35,6 +35,10 @@ pub fn outputs(
account, cur_height
);
println!();
if term::stdout().is_none() {
println!("Could not open terminal");
return Ok(());
}
let mut t = term::stdout().unwrap();
t.fg(term::color::MAGENTA).unwrap();
writeln!(t, "{}", title).unwrap();
@ -132,6 +136,10 @@ pub fn txs(
account, cur_height
);
println!();
if term::stdout().is_none() {
println!("Could not open terminal");
return Ok(());
}
let mut t = term::stdout().unwrap();
t.fg(term::color::MAGENTA).unwrap();
writeln!(t, "{}", title).unwrap();
@ -409,6 +417,10 @@ pub fn accounts(acct_mappings: Vec<AcctPathMapping>) {
pub fn tx_messages(tx: &TxLogEntry, dark_background_color_scheme: bool) -> Result<(), Error> {
let title = format!("Transaction Messages - Transaction '{}'", tx.id,);
println!();
if term::stdout().is_none() {
println!("Could not open terminal");
return Ok(());
}
let mut t = term::stdout().unwrap();
t.fg(term::color::MAGENTA).unwrap();
writeln!(t, "{}", title).unwrap();