Adds a little more context
This commit is contained in:
parent
ceb37562fa
commit
641bc50dbb
|
|
@ -1,5 +1,6 @@
|
|||
use std::{fs::File, io::Write, process::Command};
|
||||
|
||||
use anyhow::Context;
|
||||
use regex::Regex;
|
||||
use xshell::Shell;
|
||||
|
||||
|
|
@ -55,13 +56,13 @@ fn run_coverage(sh: &Shell) -> Result<(), anyhow::Error> {
|
|||
|
||||
fn run_version(sh: &Shell) -> Result<(), anyhow::Error> {
|
||||
println!("Finding version...");
|
||||
let manifest = sh.read_file("Cargo.toml")?;
|
||||
let manifest = sh.read_file("Cargo.toml").context("Opening Cargo.toml")?;
|
||||
let version = manifest
|
||||
.split_once("version = \"")
|
||||
.and_then(|it| it.1.split_once('\"'))
|
||||
.map(|it| it.0)
|
||||
.ok_or_else(|| anyhow::format_err!("can't find version field in the manifest"))?;
|
||||
write_badge("version", version, "orange", "version")?;
|
||||
write_badge("version", version, "orange", "version").context("Writing version badge")?;
|
||||
println!(" Done!");
|
||||
Ok(())
|
||||
}
|
||||
|
|
@ -84,7 +85,8 @@ fn run_version(sh: &Shell) -> Result<(), anyhow::Error> {
|
|||
fn write_badge(name: &str, value: &str, color: &str, test_name: &str) -> Result<(), anyhow::Error> {
|
||||
let output = Command::new("badge-maker")
|
||||
.args(vec!["-s", "plastic", name, value, "-c", color])
|
||||
.output()?;
|
||||
.output()
|
||||
.context("Running badge-maker to export the badge")?;
|
||||
let mut f = File::create(format!("badges/{}.svg", test_name)).unwrap();
|
||||
f.write_all(&output.stdout)?;
|
||||
// if let Ok(badge_out) = cmd!(sh, "badge-maker -s plastic build failed -c red")
|
||||
|
|
|
|||
Loading…
Reference in New Issue