diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 87b1a43..1c93b65 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -4,6 +4,17 @@ concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true jobs: + ci: + runs-on: ubuntu-latest + permissions: + checks: read + needs: [lockfile, lint] + steps: + - name: Wait for checks + uses: poseidon/wait-for-status-checks@v0.6.0 + with: + token: ${{ secrets.GITHUB_TOKEN }} + match_pattern: test lockfile: runs-on: ubuntu-latest steps: diff --git a/Cargo.lock b/Cargo.lock index 862e2d3..4450aa9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -59,9 +59,9 @@ dependencies = [ "clap", "clap-verbosity-flag", "colorchoice-clap", + "eyre", "owo-colors", "proc-exit", - "thiserror", "tracing", "tracing-log 0.1.4", "tracing-subscriber", @@ -156,12 +156,28 @@ dependencies = [ "windows-sys 0.52.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 = "heck" version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" +[[package]] +name = "indenter" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce23b50ad8242c51a442f3ff322d56b02f08852c77e4c0b4d3fd684abc89c683" + [[package]] name = "is_terminal_polyfill" version = "1.70.0" @@ -305,26 +321,6 @@ dependencies = [ "windows-sys 0.48.0", ] -[[package]] -name = "thiserror" -version = "1.0.62" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2675633b1499176c2dff06b0856a27976a8f9d436737b4cf4f312d4d91d8bbb" -dependencies = [ - "thiserror-impl", -] - -[[package]] -name = "thiserror-impl" -version = "1.0.62" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d20468752b09f49e909e55a5d338caa8bedf615594e9d80bc4c565d30faf798c" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "thread_local" version = "1.1.8" diff --git a/Cargo.toml b/Cargo.toml index 7068c88..eb9e575 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,9 +19,9 @@ anstream = "0.6.4" clap = { version = "4.4.7", features = ["derive", "wrap_help"] } clap-verbosity-flag = "2.1.0" colorchoice-clap = "1.0.3" +eyre = "0.6.12" owo-colors = "3.5.0" proc-exit = "2.0.1" -thiserror = "1.0.39" tracing = "0.1.37" tracing-log = { version = "0.1.3", default-features = false, features = ["log-tracer", "std"] } tracing-subscriber = "0.3.16" diff --git a/src/error.rs b/src/error.rs index 85781c7..90ad1d0 100644 --- a/src/error.rs +++ b/src/error.rs @@ -1,34 +1,20 @@ -use std::{ - io::{Error as IoError, Write}, - result::Result as StdResult, -}; +use std::io::Write; use anstream::{eprintln, stderr, stdout}; +use eyre::Result as EyreResult; use owo_colors::OwoColorize; use proc_exit::Code; -#[derive(Debug, thiserror::Error)] -pub enum Error { - #[error("{0}")] - Io(#[from] IoError), -} - -impl Error { - fn print(&self) { - eprintln!("{}: {self}", "error".red().bold()); - } - - fn code(&self) -> Code { - Code::FAILURE - } -} - -pub type Result = StdResult; +pub type Result = EyreResult; pub fn finish(result: Result) { let code = if let Some(e) = result.err() { - e.print(); - e.code() + // Use `e.is::()` to check for a specific error + // in order to wrap all instances of it. + let err = e; + + eprintln!("{}: {err}", "error".red().bold()); + Code::FAILURE } else { Code::SUCCESS };