diff options
Diffstat (limited to 'src/cli.rs')
| -rw-r--r-- | src/cli.rs | 13 |
1 files changed, 10 insertions, 3 deletions
@@ -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), + } +} |