chore: replace anyhow with color_eyre
This commit is contained in:
parent
5573bf19f8
commit
daf560318d
10 changed files with 23 additions and 17 deletions
|
@ -5,8 +5,8 @@ edition = "2021"
|
||||||
publish = false # NOTE: Not a CLI tool or a library, so don't release to crates.io
|
publish = false # NOTE: Not a CLI tool or a library, so don't release to crates.io
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
anyhow = "1.0"
|
|
||||||
bon = "3.0"
|
bon = "3.0"
|
||||||
|
color-eyre = "0.6"
|
||||||
file-format = { version = "0.26", features = ["reader-txt"] }
|
file-format = { version = "0.26", features = ["reader-txt"] }
|
||||||
ignore = "0.4"
|
ignore = "0.4"
|
||||||
kxio = "5.0"
|
kxio = "5.0"
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
use crate::model::Config;
|
use crate::model::Config;
|
||||||
use crate::patterns::issue_pattern;
|
use crate::patterns::issue_pattern;
|
||||||
use crate::printer::Printer;
|
use crate::printer::Printer;
|
||||||
use anyhow::{Context, Result};
|
use color_eyre::{eyre::Context, Result};
|
||||||
use kxio::{fs::FileSystem, net::Net};
|
use kxio::{fs::FileSystem, net::Net};
|
||||||
|
|
||||||
pub fn init_config<'net, 'fs>(
|
pub fn init_config<'net, 'fs>(
|
||||||
|
|
|
@ -3,7 +3,7 @@ use std::collections::HashSet;
|
||||||
|
|
||||||
use crate::model::Config;
|
use crate::model::Config;
|
||||||
|
|
||||||
use anyhow::Result;
|
use color_eyre::Result;
|
||||||
|
|
||||||
use super::Issue;
|
use super::Issue;
|
||||||
|
|
||||||
|
|
10
src/main.rs
10
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 init::init_config;
|
||||||
use issues::fetch_open_issues;
|
use issues::fetch_open_issues;
|
||||||
use printer::{Printer, StandardPrinter};
|
use printer::{Printer, StandardPrinter};
|
||||||
|
@ -18,13 +21,14 @@ mod tests;
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
#[cfg(not(tarpaulin_include))]
|
#[cfg(not(tarpaulin_include))]
|
||||||
#[cfg_attr(test, mutants::skip)]
|
#[cfg_attr(test, mutants::skip)]
|
||||||
async fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
|
async fn main() -> Result<()> {
|
||||||
|
color_eyre::install()?;
|
||||||
let github_workspace = std::env::var("GITHUB_WORKSPACE").context("GITHUB_WORKSPACE")?;
|
let github_workspace = std::env::var("GITHUB_WORKSPACE").context("GITHUB_WORKSPACE")?;
|
||||||
let fs = kxio::fs::new(github_workspace);
|
let fs = kxio::fs::new(github_workspace);
|
||||||
|
|
||||||
let net = kxio::net::new();
|
let net = kxio::net::new();
|
||||||
|
|
||||||
Ok(run(&StandardPrinter, &fs, &net).await?)
|
run(&StandardPrinter, &fs, &net).await
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn run(
|
async fn run(
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
//
|
//
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
use anyhow::{Context, Result};
|
|
||||||
use bon::Builder;
|
use bon::Builder;
|
||||||
|
use color_eyre::{eyre::ContextCompat as _, Result};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
issues::Issue,
|
issues::Issue,
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
//
|
//
|
||||||
use anyhow::Result;
|
use color_eyre::Result;
|
||||||
|
|
||||||
use crate::{patterns::issue_pattern, tests::a_config};
|
use crate::{patterns::issue_pattern, tests::a_config};
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests;
|
mod tests;
|
||||||
|
|
||||||
use anyhow::{Context as _, Result};
|
use color_eyre::{eyre::Context as _, Result};
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
|
|
||||||
const MARKER_RE: &str = r"(#|//)\s*(TODO|FIXME):?";
|
const MARKER_RE: &str = r"(#|//)\s*(TODO|FIXME):?";
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use anyhow::Result;
|
use color_eyre::Result;
|
||||||
|
|
||||||
//
|
//
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
|
use color_eyre::Result;
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn when_todo_find_marker() -> anyhow::Result<()> {
|
fn when_todo_find_marker() -> Result<()> {
|
||||||
//given
|
//given
|
||||||
let line = " a line // TODO: with a marker";
|
let line = " a line // TODO: with a marker";
|
||||||
|
|
||||||
|
@ -15,7 +17,7 @@ fn when_todo_find_marker() -> anyhow::Result<()> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn when_fixme_find_marker() -> anyhow::Result<()> {
|
fn when_fixme_find_marker() -> Result<()> {
|
||||||
//given
|
//given
|
||||||
let line = " a line // FIXME: with a marker";
|
let line = " a line // FIXME: with a marker";
|
||||||
|
|
||||||
|
@ -29,7 +31,7 @@ fn when_fixme_find_marker() -> anyhow::Result<()> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn when_no_marker_find_nothing() -> anyhow::Result<()> {
|
fn when_no_marker_find_nothing() -> Result<()> {
|
||||||
//given
|
//given
|
||||||
let line = " a line with no marker";
|
let line = " a line with no marker";
|
||||||
|
|
||||||
|
@ -43,7 +45,7 @@ fn when_no_marker_find_nothing() -> anyhow::Result<()> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn when_invalid_todo_find_nothing() -> anyhow::Result<()> {
|
fn when_invalid_todo_find_nothing() -> Result<()> {
|
||||||
//given
|
//given
|
||||||
let line = " a line TODO: with no real marker";
|
let line = " a line TODO: with no real marker";
|
||||||
|
|
||||||
|
@ -56,7 +58,7 @@ fn when_invalid_todo_find_nothing() -> anyhow::Result<()> {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
#[test]
|
#[test]
|
||||||
fn when_invalid_fixme_find_nothing() -> anyhow::Result<()> {
|
fn when_invalid_fixme_find_nothing() -> Result<()> {
|
||||||
//given
|
//given
|
||||||
let line = " a line FIXME: with no real marker";
|
let line = " a line FIXME: with no real marker";
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ use crate::{
|
||||||
model::{Config, Line, Marker},
|
model::{Config, Line, Marker},
|
||||||
printer::Printer,
|
printer::Printer,
|
||||||
};
|
};
|
||||||
use anyhow::{Context as _, Result};
|
use color_eyre::{eyre::Context as _, Result};
|
||||||
use file_format::FileFormat;
|
use file_format::FileFormat;
|
||||||
use ignore::Walk;
|
use ignore::Walk;
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ pub fn find_markers(
|
||||||
config: &Config,
|
config: &Config,
|
||||||
issues: HashSet<Issue>,
|
issues: HashSet<Issue>,
|
||||||
file_scanner: &impl FileScanner,
|
file_scanner: &impl FileScanner,
|
||||||
) -> Result<u32, anyhow::Error> {
|
) -> Result<u32> {
|
||||||
let mut errors = 0;
|
let mut errors = 0;
|
||||||
for file in Walk::new(config.fs().base()).flatten() {
|
for file in Walk::new(config.fs().base()).flatten() {
|
||||||
let path = file.path();
|
let path = file.path();
|
||||||
|
|
Loading…
Reference in a new issue