summaryrefslogtreecommitdiff
path: root/src/cli.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/cli.rs')
-rw-r--r--src/cli.rs20
1 files changed, 18 insertions, 2 deletions
diff --git a/src/cli.rs b/src/cli.rs
index c91d4fd..1b62cd9 100644
--- a/src/cli.rs
+++ b/src/cli.rs
@@ -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")
+ }
+ }
}
}