diff options
Diffstat (limited to 'src/cli.rs')
| -rw-r--r-- | src/cli.rs | 20 |
1 files changed, 18 insertions, 2 deletions
@@ -3,6 +3,8 @@ use std::path::PathBuf; use anyhow::{bail, Result}; use clap::{Parser, Subcommand}; +use crate::compare::compare; +use crate::manifest::ArtifactManifest; use crate::{BuildPlan, ImageSpec}; #[derive(Debug, Parser)] @@ -56,7 +58,21 @@ pub fn run(cli: Cli) -> Result<()> { Ok(()) } Command::Build { .. } => bail!("build execution is not available yet"), - Command::Inspect { .. } => bail!("artifact inspection is not available yet"), - Command::Compare { .. } => bail!("artifact comparison is not available yet"), + Command::Inspect { artifact } => { + let manifest = ArtifactManifest::load(&artifact)?; + println!("{}", toml::to_string_pretty(&manifest)?); + Ok(()) + } + Command::Compare { left, right } => { + let left = ArtifactManifest::load(&left)?; + let right = ArtifactManifest::load(&right)?; + let report = compare(&left, &right); + print!("{}", report.render()); + if report.is_equivalent() { + Ok(()) + } else { + bail!("artifacts differ semantically") + } + } } } |