From db73ad395220aff5ae7e10f569e308740d0040fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e=20Ravier?= Date: Wed, 17 Apr 2024 01:25:47 +0200 Subject: [PATCH] cli: Add --json support to --check This will let higher level tools (Plasma Discover for example) more easily read the output of `bootc update --check --json`. --- lib/src/cli.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/src/cli.rs b/lib/src/cli.rs index 05f1b2b7..46cf800e 100644 --- a/lib/src/cli.rs +++ b/lib/src/cli.rs @@ -39,6 +39,10 @@ pub(crate) struct UpgradeOpts { #[clap(long, conflicts_with = "apply")] pub(crate) check: bool, + /// Output JSON + #[clap(long, conflicts_with = "apply", required_if_eq("check", "true"))] + pub(crate) json: bool, + /// Restart or reboot into the new target image. /// /// Currently, this option always reboots. In the future this command @@ -433,7 +437,7 @@ async fn upgrade(opts: UpgradeOpts) -> Result<()> { if let Some(previous_image) = booted_image.as_ref() { let diff = ostree_container::ManifestDiff::new(&previous_image.manifest, &r.manifest); - diff.print(); + diff.print(opts.json); } } } @@ -466,7 +470,7 @@ async fn upgrade(opts: UpgradeOpts) -> Result<()> { if let Some(fetched_manifest) = fetched.get_manifest(repo)? { let diff = ostree_container::ManifestDiff::new(&prev.manifest, &fetched_manifest); - diff.print(); + diff.print(opts.json); } } }