From 9201add7e066e158344775b1d6dd3fe40c273958 Mon Sep 17 00:00:00 2001 From: phiresky Date: Tue, 18 Jun 2019 21:39:33 +0200 Subject: [PATCH] use exitfailure for cleaner fail output --- .travis.yml | 2 +- Cargo.lock | 10 ++++++++++ Cargo.toml | 1 + ci/before_deploy.sh | 6 +++++- src/bin/rga-preproc.rs | 12 +++--------- src/bin/rga.rs | 2 +- src/preproc.rs | 3 +-- 7 files changed, 22 insertions(+), 14 deletions(-) diff --git a/.travis.yml b/.travis.yml index 9e4181e..8cc7010 100644 --- a/.travis.yml +++ b/.travis.yml @@ -36,7 +36,7 @@ before_deploy: ci/before_deploy.sh deploy: provider: releases file_glob: true - file: deployment/${PROJECT_NAME}-${TRAVIS_TAG}-${TARGET}.tar.gz + file: deployment/${PROJECT_NAME}-${TRAVIS_TAG}-${TARGET}.* skip_cleanup: true on: condition: $TRAVIS_RUST_VERSION = nightly diff --git a/Cargo.lock b/Cargo.lock index 79402ed..ddafb8a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -305,6 +305,14 @@ dependencies = [ "termcolor 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "exitfailure" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "failure" version = "0.1.5" @@ -939,6 +947,7 @@ dependencies = [ "encoding_rs 0.8.17 (registry+https://github.com/rust-lang/crates.io-index)", "encoding_rs_io 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", + "exitfailure 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "flate2 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)", "glob 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1425,6 +1434,7 @@ dependencies = [ "checksum encoding_rs 0.8.17 (registry+https://github.com/rust-lang/crates.io-index)" = "4155785c79f2f6701f185eb2e6b4caf0555ec03477cb4c70db67b465311620ed" "checksum encoding_rs_io 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "9619ee7a2bf4e777e020b95c1439abaf008f8ea8041b78a0552c4f1bcf4df32c" "checksum env_logger 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b61fa891024a945da30a9581546e8cfaf5602c7b3f4c137a2805cf388f92075a" +"checksum exitfailure 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2ff5bd832af37f366c6c194d813a11cd90ac484f124f079294f28e357ae40515" "checksum failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "795bd83d3abeb9220f257e597aa0080a508b27533824adf336529648f6abf7e2" "checksum failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "ea1063915fd7ef4309e222a5a07cf9c319fb9c7836b1f89b85458672dbb127e1" "checksum fallible-iterator 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4443176a9f2c162692bd3d352d745ef9413eec5782a80d8fd6f8a1ac692a07f7" diff --git a/Cargo.toml b/Cargo.toml index de59c9a..d85b4e2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -44,3 +44,4 @@ structopt = "0.2.16" paste = "0.1.5" tempfile = "3.0.8" glob = "0.3.0" +exitfailure = "0.5.1" diff --git a/ci/before_deploy.sh b/ci/before_deploy.sh index 5c93d4b..c7902c5 100755 --- a/ci/before_deploy.sh +++ b/ci/before_deploy.sh @@ -51,7 +51,11 @@ mk_tarball() { # cp "$cargo_out_dir"/{rg.bash,rg.fish,_rg.ps1} "$staging/complete/" # cp complete/_rg "$staging/complete/" - (cd "$tmpdir" && tar czf "$out_dir/$name.tar.gz" "$name") + if is_windows; then + (cd "$tmpdir" && zip -r "$out_dir/$name.zip" "$name") + else + (cd "$tmpdir" && tar czf "$out_dir/$name.tar.gz" "$name") + fi rm -rf "$tmpdir" } diff --git a/src/bin/rga-preproc.rs b/src/bin/rga-preproc.rs index 6360951..efe6614 100644 --- a/src/bin/rga-preproc.rs +++ b/src/bin/rga-preproc.rs @@ -5,7 +5,7 @@ use ripgrep_all as rga; use std::fs::File; -fn main() -> Fallible<()> { +fn main() -> Result<(), exitfailure::ExitFailure> { env_logger::init(); let mut arg_arr: Vec = std::env::args_os().collect(); let last = arg_arr.pop().expect("No filename specified"); @@ -32,12 +32,6 @@ fn main() -> Fallible<()> { archive_recursion_depth: 0, config: PreprocConfig { cache, args: &args }, }; - - match rga_preproc(ai) { - Ok(()) => Ok(()), - Err(e) => { - eprintln!("preproc error: {}", e); - std::process::exit(1); - } - } + rga_preproc(ai)?; + Ok(()) } diff --git a/src/bin/rga.rs b/src/bin/rga.rs index b896d0d..a1eb5f2 100644 --- a/src/bin/rga.rs +++ b/src/bin/rga.rs @@ -8,7 +8,7 @@ use structopt::StructOpt; use std::process::Command; -fn main() -> Fallible<()> { +fn main() -> Result<(), exitfailure::ExitFailure> { env_logger::init(); let (args, passthrough_args) = split_args()?; diff --git a/src/preproc.rs b/src/preproc.rs index 6ace297..0716159 100644 --- a/src/preproc.rs +++ b/src/preproc.rs @@ -2,8 +2,7 @@ use crate::adapters::*; use crate::args::RgaArgs; use crate::matching::*; use crate::CachingWriter; -use failure::Fallible; -use failure::{format_err, Error}; +use failure::*; use log::*; use path_clean::PathClean; use std::convert::TryInto;