Skip to content

Commit

Permalink
tidyup: Reduce unnecessary complexity in terminal styling
Browse files Browse the repository at this point in the history
  • Loading branch information
crazyscot committed Dec 26, 2024
1 parent b54ee50 commit 1194c24
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 53 deletions.
36 changes: 0 additions & 36 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ rustls-log = ["quinn/rustls-log"]
[dependencies]
anstream = "0.6.18"
anstyle = "1.0.10"
anstyle-owo-colors = "2.0.3"
anyhow = "1.0.94"
capnp = "0.20.3"
capnp-futures = "0.20.1"
Expand All @@ -48,7 +47,6 @@ humanize-rs = "0.1.5"
indicatif = { version = "0.17.9", features = ["tokio"] }
lazy_static = "1.5.0"
num-format = { version = "0.4.4" }
owo-colors = { version = "4.1.0", features = ["supports-color"] }
quinn = { version = "0.11.6", default-features = false, features = ["runtime-tokio", "rustls", "ring"] }
rcgen = { version = "0.13.1" }
rustls-pki-types = "1.10.0"
Expand Down
7 changes: 3 additions & 4 deletions src/cli/cli_main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

use std::process::ExitCode;

use super::{args::CliArgs, styles::ERROR_S};
use super::args::CliArgs;
use crate::{
client::{client_main, Parameters as ClientParameters, MAX_UPDATE_FPS},
config::{Configuration, Manager},
Expand All @@ -14,7 +14,6 @@ use crate::{

use anstream::{eprintln, println};
use indicatif::{MultiProgress, ProgressDrawTarget};
use owo_colors::OwoColorize as _;
use tracing::error_span;

/// Computes the trace level for a given set of [ClientParameters]
Expand Down Expand Up @@ -59,15 +58,15 @@ pub async fn cli() -> anyhow::Result<ExitCode> {
let config_manager = match Manager::try_from(&args) {
Ok(m) => m,
Err(err) => {
eprintln!("{}: {err}", "ERROR".style(*ERROR_S));
eprintln!("ERROR: {err}");
return Ok(ExitCode::FAILURE);
}
};

let config = match config_manager.get::<Configuration>() {
Ok(c) => c,
Err(err) => {
eprintln!("{}: Failed to parse configuration", "ERROR".style(*ERROR_S));
eprintln!("ERROR: Failed to parse configuration");
err.into_iter().for_each(|e| eprintln!("{e}"));
return Ok(ExitCode::FAILURE);
}
Expand Down
12 changes: 1 addition & 11 deletions src/cli/styles.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,13 @@
#[allow(clippy::enum_glob_use)]
use anstyle::AnsiColor::*;
use anstyle::Color::Ansi;
use anstyle_owo_colors::to_owo_style;
use clap::builder::styling::Styles;
use lazy_static::lazy_static;
use owo_colors::Style as OwoStyle;

pub(crate) const ERROR: anstyle::Style = anstyle::Style::new().bold().fg_color(Some(Ansi(Red)));
pub(crate) const WARNING: anstyle::Style =
anstyle::Style::new().bold().fg_color(Some(Ansi(Yellow)));
pub(crate) const INFO: anstyle::Style = anstyle::Style::new().fg_color(Some(Ansi(Cyan)));
pub(crate) const DEBUG: anstyle::Style = anstyle::Style::new().fg_color(Some(Ansi(Blue)));

lazy_static! {
pub(crate) static ref ERROR_S: OwoStyle = to_owo_style(ERROR);
pub(crate) static ref WARNING_S: OwoStyle = to_owo_style(WARNING);
pub(crate) static ref INFO_S: OwoStyle = to_owo_style(INFO);
pub(crate) static ref DEBUG_S: OwoStyle = to_owo_style(DEBUG);
}
// pub(crate) const DEBUG: anstyle::Style = anstyle::Style::new().fg_color(Some(Ansi(Blue)));

pub(crate) const CALL_OUT: anstyle::Style = anstyle::Style::new()
.underline()
Expand Down

0 comments on commit 1194c24

Please sign in to comment.