diff --git a/Cargo.toml b/Cargo.toml index cfe337f..ec81216 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,8 +5,8 @@ edition = "2021" publish = false # NOTE: Not a CLI tool or a library, so don't release to crates.io [dependencies] -anyhow = "1.0" bon = "3.0" +color-eyre = "0.6" file-format = { version = "0.26", features = ["reader-txt"] } ignore = "0.4" kxio = "5.0" diff --git a/src/init.rs b/src/init.rs index 22d2c98..db52bc5 100644 --- a/src/init.rs +++ b/src/init.rs @@ -2,7 +2,7 @@ use crate::model::Config; use crate::patterns::issue_pattern; use crate::printer::Printer; -use anyhow::{Context, Result}; +use color_eyre::{eyre::Context, Result}; use kxio::{fs::FileSystem, net::Net}; pub fn init_config<'net, 'fs>( diff --git a/src/issues/fetch.rs b/src/issues/fetch.rs index fed3fc4..b8340ed 100644 --- a/src/issues/fetch.rs +++ b/src/issues/fetch.rs @@ -3,7 +3,7 @@ use std::collections::HashSet; use crate::model::Config; -use anyhow::Result; +use color_eyre::Result; use super::Issue; diff --git a/src/main.rs b/src/main.rs index fa81b18..52f9347 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,5 +1,8 @@ // -use anyhow::{bail, Context as _, Result}; +use color_eyre::{ + eyre::{bail, Context as _}, + Result, +}; use init::init_config; use issues::fetch_open_issues; use printer::{Printer, StandardPrinter}; @@ -18,13 +21,14 @@ mod tests; #[tokio::main] #[cfg(not(tarpaulin_include))] #[cfg_attr(test, mutants::skip)] -async fn main() -> std::result::Result<(), Box> { +async fn main() -> Result<()> { + color_eyre::install()?; let github_workspace = std::env::var("GITHUB_WORKSPACE").context("GITHUB_WORKSPACE")?; let fs = kxio::fs::new(github_workspace); let net = kxio::net::new(); - Ok(run(&StandardPrinter, &fs, &net).await?) + run(&StandardPrinter, &fs, &net).await } async fn run( diff --git a/src/model/line.rs b/src/model/line.rs index 09f3f91..2ccd101 100644 --- a/src/model/line.rs +++ b/src/model/line.rs @@ -1,8 +1,8 @@ // use std::path::PathBuf; -use anyhow::{Context, Result}; use bon::Builder; +use color_eyre::{eyre::ContextCompat as _, Result}; use crate::{ issues::Issue, diff --git a/src/model/tests/config.rs b/src/model/tests/config.rs index b5a3482..190e539 100644 --- a/src/model/tests/config.rs +++ b/src/model/tests/config.rs @@ -1,5 +1,5 @@ // -use anyhow::Result; +use color_eyre::Result; use crate::{patterns::issue_pattern, tests::a_config}; diff --git a/src/patterns/mod.rs b/src/patterns/mod.rs index 873d9ca..ea4f676 100644 --- a/src/patterns/mod.rs +++ b/src/patterns/mod.rs @@ -2,7 +2,7 @@ #[cfg(test)] mod tests; -use anyhow::{Context as _, Result}; +use color_eyre::{eyre::Context as _, Result}; use regex::Regex; const MARKER_RE: &str = r"(#|//)\s*(TODO|FIXME):?"; diff --git a/src/patterns/tests/issue.rs b/src/patterns/tests/issue.rs index d8d5704..ddd22df 100644 --- a/src/patterns/tests/issue.rs +++ b/src/patterns/tests/issue.rs @@ -1,4 +1,4 @@ -use anyhow::Result; +use color_eyre::Result; // use super::*; diff --git a/src/patterns/tests/marker.rs b/src/patterns/tests/marker.rs index d596e8d..d060c6c 100644 --- a/src/patterns/tests/marker.rs +++ b/src/patterns/tests/marker.rs @@ -1,7 +1,9 @@ +use color_eyre::Result; + use super::*; #[test] -fn when_todo_find_marker() -> anyhow::Result<()> { +fn when_todo_find_marker() -> Result<()> { //given let line = " a line // TODO: with a marker"; @@ -15,7 +17,7 @@ fn when_todo_find_marker() -> anyhow::Result<()> { } #[test] -fn when_fixme_find_marker() -> anyhow::Result<()> { +fn when_fixme_find_marker() -> Result<()> { //given let line = " a line // FIXME: with a marker"; @@ -29,7 +31,7 @@ fn when_fixme_find_marker() -> anyhow::Result<()> { } #[test] -fn when_no_marker_find_nothing() -> anyhow::Result<()> { +fn when_no_marker_find_nothing() -> Result<()> { //given let line = " a line with no marker"; @@ -43,7 +45,7 @@ fn when_no_marker_find_nothing() -> anyhow::Result<()> { } #[test] -fn when_invalid_todo_find_nothing() -> anyhow::Result<()> { +fn when_invalid_todo_find_nothing() -> Result<()> { //given let line = " a line TODO: with no real marker"; @@ -56,7 +58,7 @@ fn when_invalid_todo_find_nothing() -> anyhow::Result<()> { Ok(()) } #[test] -fn when_invalid_fixme_find_nothing() -> anyhow::Result<()> { +fn when_invalid_fixme_find_nothing() -> Result<()> { //given let line = " a line FIXME: with no real marker"; diff --git a/src/scanner.rs b/src/scanner.rs index 65e54e3..9604dba 100644 --- a/src/scanner.rs +++ b/src/scanner.rs @@ -6,7 +6,7 @@ use crate::{ model::{Config, Line, Marker}, printer::Printer, }; -use anyhow::{Context as _, Result}; +use color_eyre::{eyre::Context as _, Result}; use file_format::FileFormat; use ignore::Walk; @@ -25,7 +25,7 @@ pub fn find_markers( config: &Config, issues: HashSet, file_scanner: &impl FileScanner, -) -> Result { +) -> Result { let mut errors = 0; for file in Walk::new(config.fs().base()).flatten() { let path = file.path();