chore(deps): remove color_eyre and other unneeded features

This commit is contained in:
Alexandre Pasmantier 2025-01-25 14:22:45 +01:00
parent 1e8c8dbc96
commit 0b41906b6c
24 changed files with 62 additions and 151 deletions

68
Cargo.lock generated
View File

@ -103,6 +103,12 @@ dependencies = [
"windows-sys 0.59.0",
]
[[package]]
name = "anyhow"
version = "1.0.95"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "34ac096ce696dc2fcabef30516bb13c0a68a11d30131d3df6f04711467681b04"
[[package]]
name = "autocfg"
version = "1.4.0"
@ -381,33 +387,6 @@ dependencies = [
"winapi",
]
[[package]]
name = "color-eyre"
version = "0.6.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "55146f5e46f237f7423d74111267d4597b59b0dad0ffaf7303bce9945d843ad5"
dependencies = [
"backtrace",
"color-spantrace",
"eyre",
"indenter",
"once_cell",
"owo-colors",
"tracing-error",
]
[[package]]
name = "color-spantrace"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cd6be1b2a7e382e2b98b43b2adcca6bb0e465af0bdd38123873ae61eb17a72c2"
dependencies = [
"once_cell",
"owo-colors",
"tracing-core",
"tracing-error",
]
[[package]]
name = "colorchoice"
version = "1.0.3"
@ -709,16 +688,6 @@ dependencies = [
"windows-sys 0.59.0",
]
[[package]]
name = "eyre"
version = "0.6.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7cd915d99f24784cdc19fd37ef22b97e3ff0ae756c7e492e9fbfe897d61e2aec"
dependencies = [
"indenter",
"once_cell",
]
[[package]]
name = "fastrand"
version = "2.3.0"
@ -888,12 +857,6 @@ dependencies = [
"winapi-util",
]
[[package]]
name = "indenter"
version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ce23b50ad8242c51a442f3ff322d56b02f08852c77e4c0b4d3fd684abc89c683"
[[package]]
name = "indexmap"
version = "2.7.1"
@ -1272,12 +1235,6 @@ version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39"
[[package]]
name = "owo-colors"
version = "3.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c1b04fb49957986fdce4d6ee7a65027d55d4b6d2265e5848bbb507b58ccfdb6f"
[[package]]
name = "parking_lot"
version = "0.12.3"
@ -1846,10 +1803,10 @@ dependencies = [
name = "television"
version = "0.9.4"
dependencies = [
"anyhow",
"bat",
"better-panic",
"clap",
"color-eyre",
"copypasta",
"criterion",
"crossterm",
@ -2070,16 +2027,6 @@ dependencies = [
"valuable",
]
[[package]]
name = "tracing-error"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8b1581020d7a273442f5b45074a6a57d5757ad0a47dac0e9f0bd57b81936f3db"
dependencies = [
"tracing",
"tracing-subscriber",
]
[[package]]
name = "tracing-log"
version = "0.2.0"
@ -2101,7 +2048,6 @@ dependencies = [
"nu-ansi-term 0.46.0",
"once_cell",
"regex",
"serde",
"sharded-slab",
"smallvec",
"thread_local",

View File

@ -30,13 +30,13 @@ path = "television/lib.rs"
[dependencies]
television-derive = { path = "television-derive", version = "0.0.23" }
anyhow = "1.0"
directories = "5.0"
devicons = "0.6"
color-eyre = { version = "0.6" }
lazy_static = "1.5"
tokio = { version = "1.43", features = ["full"] }
tracing = "0.1"
tracing-subscriber = { version = "0.3", features = ["env-filter", "serde"] }
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
rustc-hash = "2.1"
syntect = { version = "5.2", default-features = false }
unicode-width = "0.2"
@ -69,7 +69,7 @@ toml = "0.8"
winapi-util = "0.1.9"
[dev-dependencies]
criterion = "0.5.1"
criterion = "0.5"
[features]
simd = ["dep:simdutf8"]

View File

@ -2,7 +2,7 @@ use rustc_hash::FxHashSet;
use std::sync::Arc;
use crate::screen::mode::Mode;
use color_eyre::Result;
use anyhow::Result;
use tokio::sync::{mpsc, Mutex};
use tracing::{debug, info};

View File

@ -3,7 +3,7 @@ use std::path::PathBuf;
use rustc_hash::FxHashMap;
use crate::channels::cable::{CableChannelPrototype, CableChannels};
use color_eyre::Result;
use anyhow::Result;
use tracing::{debug, error};
use crate::config::get_config_dir;

View File

@ -8,7 +8,7 @@ use std::collections::HashSet;
use std::io::{BufRead, BufReader};
use std::process::Stdio;
use color_eyre::Result;
use anyhow::Result;
use lazy_static::lazy_static;
use regex::Regex;
use rustc_hash::{FxBuildHasher, FxHashSet};

View File

@ -1,5 +1,5 @@
use crate::channels::entry::Entry;
use color_eyre::Result;
use anyhow::Result;
use rustc_hash::FxHashSet;
use television_derive::{Broadcast, ToCliChannel, ToUnitChannel};

View File

@ -5,8 +5,8 @@ use crate::channels::cable::{CableChannelPrototype, CableChannels};
use crate::channels::entry::{Entry, PreviewType};
use crate::channels::{CliTvChannel, OnAir, TelevisionChannel, UnitChannel};
use crate::matcher::{config::Config, Matcher};
use anyhow::Result;
use clap::ValueEnum;
use color_eyre::Result;
use devicons::FileIcon;
use rustc_hash::{FxBuildHasher, FxHashSet};
@ -83,7 +83,7 @@ impl RemoteControl {
}
None => match UnitChannel::try_from(channel_name) {
Ok(channel) => Ok(channel.into()),
Err(_) => Err(color_eyre::eyre::eyre!(
Err(_) => Err(anyhow::anyhow!(
"No channel or cable channel prototype found for {}",
channel_name
)),

View File

@ -1,8 +1,8 @@
use rustc_hash::FxHashMap;
use std::path::Path;
use anyhow::{anyhow, Result};
use clap::{Parser, Subcommand, ValueEnum};
use color_eyre::{eyre::eyre, Result};
use tracing::debug;
use crate::channels::{
@ -186,7 +186,7 @@ fn parse_channel(channel: &str) -> Result<ParsedCliChannel> {
// try to parse the channel as a builtin channel
CliTvChannel::try_from(channel)
.map(ParsedCliChannel::Builtin)
.map_err(|_| eyre!("Unknown channel: {}", channel))
.map_err(|_| anyhow!("Unknown channel: {}", channel))
},
|(_, v)| Ok(ParsedCliChannel::Cable(v.clone())),
)
@ -251,7 +251,7 @@ pub fn guess_channel_from_prompt(
if prompt.trim().is_empty() {
return match command_mapping.get("") {
Some(channel) => parse_channel(channel),
None => Err(eyre!("No channel found for prompt: {}", prompt)),
None => Err(anyhow!("No channel found for prompt: {}", prompt)),
};
}
let rev_prompt_words = prompt.split_whitespace().rev();
@ -280,7 +280,7 @@ pub fn guess_channel_from_prompt(
// reset the stack
stack.clear();
}
Err(eyre!("No channel found for prompt: {}", prompt))
Err(anyhow!("No channel found for prompt: {}", prompt))
}
#[allow(clippy::unnecessary_wraps)]

View File

@ -77,7 +77,7 @@ pub enum SerializedBinding {
}
impl<'de> Deserialize<'de> for KeyBindings {
fn deserialize<D>(deserializer: D) -> color_eyre::Result<Self, D::Error>
fn deserialize<D>(deserializer: D) -> anyhow::Result<Self, D::Error>
where
D: Deserializer<'de>,
{
@ -123,7 +123,7 @@ impl<'de> Deserialize<'de> for KeyBindings {
}
}
pub fn parse_key_event(raw: &str) -> color_eyre::Result<KeyEvent, String> {
pub fn parse_key_event(raw: &str) -> anyhow::Result<KeyEvent, String> {
let raw_lower = raw.to_ascii_lowercase();
let (remaining, modifiers) = extract_modifiers(&raw_lower);
parse_key_code_with_modifiers(remaining, modifiers)
@ -157,7 +157,7 @@ fn extract_modifiers(raw: &str) -> (&str, KeyModifiers) {
fn parse_key_code_with_modifiers(
raw: &str,
mut modifiers: KeyModifiers,
) -> color_eyre::Result<KeyEvent, String> {
) -> anyhow::Result<KeyEvent, String> {
let c = match raw {
"esc" => KeyCode::Esc,
"enter" => KeyCode::Enter,
@ -267,7 +267,7 @@ pub fn key_event_to_string(key_event: &KeyEvent) -> String {
key
}
pub fn parse_key(raw: &str) -> color_eyre::Result<Key, String> {
pub fn parse_key(raw: &str) -> anyhow::Result<Key, String> {
if raw.chars().filter(|c| *c == '>').count()
!= raw.chars().filter(|c| *c == '<').count()
{

View File

@ -1,7 +1,7 @@
#![allow(clippy::module_name_repetitions)]
use std::{env, path::PathBuf};
use color_eyre::{eyre::Context, Result};
use anyhow::Result;
use directories::ProjectDirs;
use keybindings::merge_keybindings;
pub use keybindings::{parse_key, Binding, KeyBindings};
@ -82,7 +82,7 @@ impl Config {
pub fn new() -> Result<Self> {
// Load the default_config values as base defaults
let default_config: Config = toml::from_str(DEFAULT_CONFIG)
.wrap_err("Error parsing default config")?;
.expect("Error parsing default config");
// initialize the config builder
let data_dir = get_data_dir();
@ -99,8 +99,12 @@ impl Config {
let path = config_dir.join(CONFIG_FILE_NAME);
let contents = std::fs::read_to_string(&path)?;
let cfg: Config = toml::from_str(&contents)
.wrap_err(format!("error parsing config: {path:?}"))?;
let cfg: Config = toml::from_str(&contents).unwrap_or_else(|_| {
warn!(
"Error parsing config file, using default configuration"
);
default_config.clone()
});
// merge keybindings with default keybindings
let keybindings = merge_keybindings(

View File

@ -1,4 +1,4 @@
use color_eyre::Result;
use anyhow::Result;
use std::path::PathBuf;
use crate::screen::colors::{

View File

@ -1,43 +1,31 @@
use std::env;
use std::panic;
use color_eyre::Result;
use anyhow::Result;
use tracing::error;
pub fn init() -> Result<()> {
let (panic_hook, eyre_hook) = color_eyre::config::HookBuilder::default()
.panic_section(format!(
"This is a bug. Consider reporting it at {}",
env!("CARGO_PKG_REPOSITORY")
))
.capture_span_trace_by_default(false)
.display_location_section(false)
.display_env_section(false)
.into_hooks();
eyre_hook.install()?;
std::panic::set_hook(Box::new(move |panic_info| {
panic::set_hook(Box::new(move |panic_info| {
// Clean up the terminal
if let Ok(mut t) = crate::tui::Tui::new(std::io::stderr()) {
if let Err(r) = t.exit() {
error!("Unable to exit Terminal: {:?}", r);
if let Err(err) = t.exit() {
error!("Unable to exit terminal: {:?}", err);
}
}
// In release builds, use human-panic to generate a friendly crash report:
#[cfg(not(debug_assertions))]
{
use human_panic::{handle_dump, metadata, print_msg};
let metadata = metadata!();
let file_path = handle_dump(&metadata, panic_info);
// prints human-panic message
print_msg(file_path, &metadata).expect(
let meta = metadata!();
let file_path = handle_dump(&meta, panic_info);
print_msg(file_path, &meta).expect(
"human-panic: printing error message to console failed",
);
eprintln!("{}", panic_hook.panic_report(panic_info)); // prints color-eyre stack trace to stderr
}
let msg = format!("{}", panic_hook.panic_report(panic_info));
error!("Error: {}", msg);
// In debug builds, use better-panic for a more detailed dev stacktrace:
#[cfg(debug_assertions)]
{
// Better Panic stacktrace that is only enabled when debugging.
better_panic::Settings::auto()
.most_recent_first(false)
.lineno_suffix(true)
@ -47,31 +35,6 @@ pub fn init() -> Result<()> {
std::process::exit(1);
}));
Ok(())
}
/// Similar to the `std::dbg!` macro, but generates `tracing` events rather
/// than printing to stdout.
///
/// By default, the verbosity level for the generated events is `DEBUG`, but
/// this can be customized.
#[macro_export]
macro_rules! trace_dbg {
(target: $target:expr, level: $level:expr, $ex:expr) => {{
match $ex {
value => {
tracing::event!(target: $target, $level, ?value, stringify!($ex));
value
}
}
}};
(level: $level:expr, $ex:expr) => {
trace_dbg!(target: module_path!(), level: $level, $ex)
};
(target: $target:expr, $ex:expr) => {
trace_dbg!(target: $target, level: tracing::Level::DEBUG, $ex)
};
($ex:expr) => {
trace_dbg!(level: tracing::Level::DEBUG, $ex)
};
}

View File

@ -2,7 +2,7 @@ use rustc_hash::FxHashMap;
use std::ops::Deref;
use crate::screen::mode::Mode;
use color_eyre::Result;
use anyhow::Result;
use crate::action::Action;
use crate::config::{Binding, KeyBindings};
@ -47,9 +47,10 @@ impl Keymap {
mode: Mode,
mappings: Vec<(Key, Action)>,
) -> Result<Self> {
let mode_keymap = self.0.get_mut(&mode).ok_or_else(|| {
color_eyre::eyre::eyre!("Mode {:?} not found", mode)
})?;
let mode_keymap = self
.0
.get_mut(&mode)
.ok_or_else(|| anyhow::anyhow!("Mode {:?} not found", mode))?;
for (key, action) in mappings {
mode_keymap.insert(key, action);
}

View File

@ -1,4 +1,4 @@
use color_eyre::Result;
use anyhow::Result;
use tracing_subscriber::{fmt, prelude::*, EnvFilter};
use crate::config::get_data_dir;

View File

@ -3,8 +3,8 @@ use std::io::{stdout, BufWriter, IsTerminal, Write};
use std::path::Path;
use std::process::exit;
use anyhow::Result;
use clap::Parser;
use color_eyre::Result;
use tracing::{debug, error, info};
use television::app::App;

View File

@ -1,4 +1,4 @@
use color_eyre::Result;
use anyhow::Result;
use ratatui::layout::Rect;
use std::{
io::{stderr, stdout, LineWriter},

View File

@ -1,5 +1,5 @@
use crate::utils::input::Input;
use color_eyre::Result;
use anyhow::Result;
use ratatui::{
layout::{
Alignment, Constraint, Direction, Layout as RatatuiLayout, Rect,

View File

@ -11,7 +11,7 @@ use crate::utils::strings::{
replace_non_printable, shrink_with_ellipsis, ReplaceNonPrintableConfig,
EMPTY_STRING,
};
use color_eyre::eyre::Result;
use anyhow::Result;
use devicons::FileIcon;
use ratatui::widgets::{Block, BorderType, Borders, Padding, Paragraph, Wrap};
use ratatui::Frame;

View File

@ -7,7 +7,7 @@ use crate::screen::mode::{mode_color, Mode};
use crate::screen::results::build_results_list;
use crate::utils::input::Input;
use color_eyre::eyre::Result;
use anyhow::Result;
use ratatui::layout::{Alignment, Constraint, Direction, Layout, Rect};
use ratatui::prelude::Style;
use ratatui::style::{Color, Stylize};

View File

@ -5,7 +5,7 @@ use crate::utils::strings::{
make_matched_string_printable, next_char_boundary,
slice_at_char_boundaries,
};
use color_eyre::eyre::Result;
use anyhow::Result;
use ratatui::layout::{Alignment, Rect};
use ratatui::prelude::{Color, Line, Span, Style};
use ratatui::style::Stylize;

View File

@ -24,7 +24,7 @@ use crate::screen::spinner::{Spinner, SpinnerState};
use crate::utils::metadata::AppMetadata;
use crate::utils::strings::EMPTY_STRING;
use crate::{cable::load_cable_channels, keymap::Keymap};
use color_eyre::Result;
use anyhow::Result;
use copypasta::{ClipboardContext, ClipboardProvider};
use ratatui::{layout::Rect, style::Color, Frame};
use rustc_hash::{FxBuildHasher, FxHashMap, FxHashSet};

View File

@ -3,7 +3,7 @@ use std::{
ops::{Deref, DerefMut},
};
use color_eyre::Result;
use anyhow::Result;
use crossterm::{
cursor, execute,
terminal::{

View File

@ -1,4 +1,4 @@
use color_eyre::Result;
use anyhow::Result;
#[derive(Debug, Clone, Copy, PartialEq)]
pub enum Shell {
@ -18,9 +18,6 @@ pub fn completion_script(shell: Shell) -> Result<&'static str> {
Shell::Bash => Ok(COMPLETION_BASH),
Shell::Zsh => Ok(COMPLETION_ZSH),
Shell::Fish => Ok(COMPLETION_FISH),
_ => color_eyre::eyre::bail!(
"This shell is not yet supported: {:?}",
shell
),
_ => anyhow::bail!("This shell is not yet supported: {:?}", shell),
}
}

View File

@ -1,5 +1,5 @@
use anyhow::Result;
use bat::assets::HighlightingAssets;
use color_eyre::Result;
use gag::Gag;
use std::path::{Path, PathBuf};
use syntect::easy::HighlightLines;