Skip to content

Commit

Permalink
print program name in version error
Browse files Browse the repository at this point in the history
  • Loading branch information
Rob Patro committed Jan 21, 2023
1 parent e155455 commit 3709e40
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ fn build_ref_and_index(af_home_path: PathBuf, index_args: Commands) -> anyhow::R
match ref_type {
ReferenceType::SplicedUnspliced => {
let v = rp.pyroe.clone().unwrap().version;
if let Err(e) = prog_utils::check_version_constraints(">=0.7.1, <1.0.0", &v)
if let Err(e) = prog_utils::check_version_constraints("pyroe", ">=0.7.1, <1.0.0", &v)
{
bail!(e);
}
Expand Down
16 changes: 10 additions & 6 deletions src/utils/prog_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ pub struct ReqProgs {
}

pub fn check_version_constraints<S1: AsRef<str>>(
prog_name: &str,
req_string: S1,
prog_ver_string: &str,
) -> Result<Version> {
Expand All @@ -43,14 +44,16 @@ pub fn check_version_constraints<S1: AsRef<str>>(
Ok(parsed_version)
} else {
Err(anyhow!(
"Parsed version {:?} does not satisfy constraints {}. Please install a compatible version.",
"Parsed version of {} ({:?}) does not satisfy constraints {}. Please install a compatible version.",
prog_name,
prog_ver_string,
req
))
}
}

pub fn check_version_constraints_from_output<S1: AsRef<str>>(
prog_name: &str,
req_string: S1,
prog_output: std::result::Result<String, std::io::Error>,
) -> Result<Version> {
Expand All @@ -64,7 +67,8 @@ pub fn check_version_constraints_from_output<S1: AsRef<str>>(
return Ok(parsed_version);
} else {
return Err(anyhow!(
"Parsed version {:?} does not satisfy constraints {}. Please install a compatible version.",
"Parsed version of {} ({:?}) does not satisfy constraints {}. Please install a compatible version.",
prog_name,
version,
req
));
Expand Down Expand Up @@ -183,7 +187,7 @@ pub fn get_required_progs_from_paths(
if let Some(piscem) = opt_piscem {
let st = piscem.display().to_string();
let sr = run_fun!($st --version);
let v = check_version_constraints_from_output(">=0.3.0, <1.0.0", sr)?;
let v = check_version_constraints_from_output("piscem", ">=0.3.0, <1.0.0", sr)?;
rp.piscem = Some(ProgInfo {
exe_path: piscem,
version: format!("{}", v),
Expand All @@ -193,7 +197,7 @@ pub fn get_required_progs_from_paths(
if let Some(salmon) = opt_salmon {
let st = salmon.display().to_string();
let sr = run_fun!($st --version);
let v = check_version_constraints_from_output(">=1.5.1, <2.0.0", sr)?;
let v = check_version_constraints_from_output("salmon", ">=1.5.1, <2.0.0", sr)?;
rp.salmon = Some(ProgInfo {
exe_path: salmon,
version: format!("{}", v),
Expand All @@ -202,15 +206,15 @@ pub fn get_required_progs_from_paths(

let st = alevin_fry.display().to_string();
let sr = run_fun!($st --version);
let v = check_version_constraints_from_output(">=0.4.1, <1.0.0", sr)?;
let v = check_version_constraints_from_output("alevin-fry", ">=0.4.1, <1.0.0", sr)?;
rp.alevin_fry = Some(ProgInfo {
exe_path: alevin_fry,
version: format!("{}", v),
});

let st = pyroe.display().to_string();
let sr = run_fun!($st --version);
let v = check_version_constraints_from_output(">=0.6.2, <1.0.0", sr)?;
let v = check_version_constraints_from_output("pyroe", ">=0.6.2, <1.0.0", sr)?;
rp.pyroe = Some(ProgInfo {
exe_path: pyroe,
version: format!("{}", v),
Expand Down

0 comments on commit 3709e40

Please sign in to comment.