summaryrefslogtreecommitdiff
path: root/src/cli.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/cli.rs')
-rw-r--r--src/cli.rs13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/cli.rs b/src/cli.rs
index 1b62cd9..4445f20 100644
--- a/src/cli.rs
+++ b/src/cli.rs
@@ -59,13 +59,13 @@ pub fn run(cli: Cli) -> Result<()> {
}
Command::Build { .. } => bail!("build execution is not available yet"),
Command::Inspect { artifact } => {
- let manifest = ArtifactManifest::load(&artifact)?;
+ let manifest = load_artifact(&artifact)?;
println!("{}", toml::to_string_pretty(&manifest)?);
Ok(())
}
Command::Compare { left, right } => {
- let left = ArtifactManifest::load(&left)?;
- let right = ArtifactManifest::load(&right)?;
+ let left = load_artifact(&left)?;
+ let right = load_artifact(&right)?;
let report = compare(&left, &right);
print!("{}", report.render());
if report.is_equivalent() {
@@ -76,3 +76,10 @@ pub fn run(cli: Cli) -> Result<()> {
}
}
}
+
+fn load_artifact(path: &std::path::Path) -> Result<ArtifactManifest> {
+ match path.extension().and_then(|extension| extension.to_str()) {
+ Some("toml") => ArtifactManifest::load(path),
+ _ => ArtifactManifest::collect_archive(path),
+ }
+}