summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@sequoia-pgp.org>2022-09-22 10:12:08 +0300
committerLars Wirzenius <liw@sequoia-pgp.org>2022-09-22 10:12:08 +0300
commit84410035da77145923acf4892c636d9622b03666 (patch)
treedc853bcfb554cfc31775662d1974b7e3fdd046bd
parent0d11e326defa94b7eec2477bafff398bd9d68d37 (diff)
downloadmissing-dependencies-84410035da77145923acf4892c636d9622b03666.tar.gz
feat: allow table style choice
The markdown style is useful to embed the tables in markdown for HTML generation and similar. Sponsored-by: pep.foundation
-rw-r--r--src/main.rs21
1 files changed, 16 insertions, 5 deletions
diff --git a/src/main.rs b/src/main.rs
index 671a1d6..0c99d2f 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -36,7 +36,7 @@ fn fallible_main() -> anyhow::Result<()> {
info!("all good");
Ok(())
} else {
- report_problems(problems);
+ report_problems(problems, &args.style);
Err(anyhow!("there were {} missing dependencies", count))
}
}
@@ -106,7 +106,7 @@ fn find_problems(packaged: &Crates, dependencies: &HashMap<String, VersionReq>)
problems.to_vec()
}
-fn report_problems(mut problems: Vec<Problem>) {
+fn report_problems(mut problems: Vec<Problem>, style: &str) {
problems.sort_by_key(|p| match p {
Problem::MissingCrate(x) => x.name.clone(),
Problem::MissingVersion(x) => x.name.clone(),
@@ -130,7 +130,11 @@ fn report_problems(mut problems: Vec<Problem>) {
let got_versions = !versions.is_empty();
if got_versions {
- let table = Table::new(versions).with(Style::modern());
+
+ let table = match style {
+ "markdown" => Table::new(versions).with(Style::markdown()),
+ _ => Table::new(versions).with(Style::modern()),
+ };
println!("Table: Packaged version is not what is required");
println!();
println!("{}", table.to_string());
@@ -140,7 +144,10 @@ fn report_problems(mut problems: Vec<Problem>) {
if got_versions {
println!();
}
- let table = Table::new(crates).with(Style::modern());
+ let table = match style {
+ "markdown" => Table::new(crates).with(Style::markdown()),
+ _ => Table::new(crates).with(Style::modern()),
+ };
println!("Table: Required crate is not packaged at all");
println!();
println!("{}", table.to_string());
@@ -159,10 +166,14 @@ struct Args {
#[clap(long)]
all_features: bool,
- /// Ask cargo for specifid features (use once per feature).
+ /// Ask cargo for specified features (use once per feature).
#[clap(short, long)]
features: Vec<String>,
+ /// Style of tables to use for reporting problems.
+ #[clap(long, possible_values = ["modern", "markdown"], default_value = "modern")]
+ style: String,
+
/// List of crates and versions packaged in the target operating system.
packaged: PathBuf,