Skip to content

Commit

Permalink
cli: Suppress terminal color in abscissa
Browse files Browse the repository at this point in the history
To avoid a panic in the terminal component initialization over
an attempt to install a global eyre handler after the application has
already done so, we need to tell the terminal to not use colors.
  • Loading branch information
mzabaluev committed Nov 23, 2021
1 parent 9c58777 commit 5cbf1be
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
9 changes: 8 additions & 1 deletion relayer-cli/src/application.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@

use std::path::PathBuf;

use abscissa_core::terminal::component::Terminal;
use abscissa_core::{
application::{self, AppCell},
component::Component,
config::{self, CfgCell},
terminal::component::Terminal,
terminal::ColorChoice,
Application, Configurable, FrameworkError, FrameworkErrorKind, StandardPaths,
};
use ibc_relayer::config::Config;
Expand Down Expand Up @@ -180,4 +181,10 @@ impl Application for CliApp {
Ok(vec![Box::new(terminal), Box::new(tracing)])
}
}

// Disable color support due to
// https://github.com/iqlusioninc/abscissa/issues/589
fn term_colors(&self, _command: &Self::Cmd) -> ColorChoice {
ColorChoice::Never
}
}
12 changes: 8 additions & 4 deletions relayer-cli/src/bin/hermes/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#![forbid(unsafe_code)]

use ibc_relayer_cli::application::APPLICATION;
use ibc_relayer_cli::components::enable_ansi;

fn main() -> eyre::Result<()> {
install_error_reporter()?;
Expand All @@ -15,11 +16,14 @@ fn install_error_reporter() -> eyre::Result<()> {
if !backtrace_enabled() {
// If backtraces are disabled, display errors in single line.
oneline_eyre::install()
} else if enable_ansi() {
// Else, if backtraces are enabled and we are in a terminal
// supporting color, display full error logs in color.
color_eyre::install()
} else {
// Otherwise, backtraces are enabled, so use the
// default error report handler. The impl for
// Application::framework_components takes care about
// initialization of color_eyre.
// Otherwise, backtraces are enabled and we are piping to logs, so use the
// default error report handler, which displays multiline errors
// without color.
Ok(())
}
}
Expand Down

0 comments on commit 5cbf1be

Please sign in to comment.