diff options
author | Doug Goldstein <cardoe@cardoe.com> | 2019-12-25 14:33:25 -0600 |
---|---|---|
committer | Doug Goldstein <cardoe@cardoe.com> | 2020-01-26 09:20:18 -0600 |
commit | 2ed2ed51bc7e82db9f211394047cb64faa3b68a2 (patch) | |
tree | 64b94dd36f78cf8b36a488e68ba9bfcac02e784d /src | |
parent | drop Cargo usage (diff) | |
download | cargo-ebuild-2ed2ed51bc7e82db9f211394047cb64faa3b68a2.tar.gz cargo-ebuild-2ed2ed51bc7e82db9f211394047cb64faa3b68a2.tar.bz2 cargo-ebuild-2ed2ed51bc7e82db9f211394047cb64faa3b68a2.zip |
convert to anyhow for modern Error
failure, while popular is deprecated as the improvements it brought to
the community have been incorporated in the std Error trait. anyhow
takes advantage of that while giving us an easy error to pass around.
Diffstat (limited to 'src')
-rw-r--r-- | src/lib.rs | 4 | ||||
-rw-r--r-- | src/main.rs | 8 |
2 files changed, 5 insertions, 7 deletions
@@ -10,7 +10,7 @@ mod metadata; -use failure::format_err; +use anyhow::{format_err, Result}; use std::collections::BTreeSet; use std::fs::OpenOptions; use std::io::Write; @@ -27,7 +27,7 @@ fn parse_license<'a>(lic_str: &'a str) -> Vec<&'a str> { .collect() } -pub fn run(verbose: u32, quiet: bool, manifest_path: Option<PathBuf>) -> Result<(), failure::Error> { +pub fn run(verbose: u32, quiet: bool, manifest_path: Option<PathBuf>) -> Result<()> { let mut cmd = cargo_metadata::MetadataCommand::new(); if let Some(path) = manifest_path { diff --git a/src/main.rs b/src/main.rs index cca4d4a..e0d550b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -11,6 +11,7 @@ extern crate cargo_ebuild; extern crate structopt; +use anyhow::Result; use cargo_ebuild::run; use std::path::PathBuf; use structopt::clap::AppSettings; @@ -44,12 +45,9 @@ enum Opt { Ebuild(Args), } -fn main() { +fn main() -> Result<()> { let Opt::Ebuild(opt) = Opt::from_args(); // run the actual code - if let Err(e) = run(opt.verbose as u32, opt.quiet, opt.manifest_path) { - eprintln!("{}", e); - ::std::process::exit(1); - } + run(opt.verbose as u32, opt.quiet, opt.manifest_path) } |