Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Human-readable bootc status #602

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion lib/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,11 @@ pub(crate) struct StatusOpts {
/// Only display status for the booted deployment.
#[clap(long)]
pub(crate) booted: bool,

/// Condense status into most important info, to reduce eye fatigue
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can probably just go ahead and default to human-readable if we're writing to a tty by default.

That avoids the need to call it anything at all, and avoids "typing fatigue" from a potentially frequently used CLI option.

Arguably then, we could also simultaneously switch to JSON by default if we're not on a tty.

But, we probably do need a general option here like:

enum OutputFormat {
  HumanReadable,
  YAML,
  JSON
}

or so and

pub(crate) format Option<OutputFormat>

or so.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#[clap(long)]
pub(crate) pretty: bool,

}

#[cfg(feature = "install")]
Expand Down Expand Up @@ -772,7 +777,8 @@ fn test_parse_opts() {
Opt::parse_including_static(["bootc", "status"]),
Opt::Status(StatusOpts {
json: false,
booted: false
booted: false,
pretty: false
})
));
}
Expand Down
11 changes: 10 additions & 1 deletion lib/src/status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,15 @@ pub(crate) async fn status(opts: super::cli::StatusOpts) -> Result<()> {
// Filter to just the serializable status structures.
let out = std::io::stdout();
let mut out = out.lock();
if opts.json {



if opts.pretty {

if let Some(&host.status.booted)

println!("Current deployment image: {:?}", &host.status.booted.unwrap().image.unwrap().image.image);
} else if opts.json {
serde_json::to_writer(&mut out, &host).context("Writing to stdout")?;
} else {
serde_yaml::to_writer(&mut out, &host).context("Writing to stdout")?;
Expand All @@ -325,6 +333,7 @@ pub(crate) async fn status(opts: super::cli::StatusOpts) -> Result<()> {
Ok(())
}


#[test]
fn test_convert_signatures() {
use std::str::FromStr;
Expand Down
Loading