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

aziot: tweak check-list flags to be consistent with check #94

Merged
merged 2 commits into from
Jan 21, 2021
Merged
Changes from 1 commit
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
26 changes: 22 additions & 4 deletions aziot/src/check_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,33 @@ use aziot_check_common::CheckListOutput;
#[derive(StructOpt, Copy, Clone)]
#[structopt(about = "List the checks that are run for 'aziot check'")]
pub struct CheckListOptions {
/// Output available checks as a JSON object.
#[structopt(short, long)]
json: bool,
/// Output format. One of "text" or "json".
#[structopt(short, long, value_name = "FORMAT", default_value = "text")]
output: OutputFormat,
}

#[derive(Clone, Copy, Debug)]
pub enum OutputFormat {
Text,
Json,
}

impl std::str::FromStr for OutputFormat {
type Err = &'static str;

fn from_str(s: &str) -> Result<Self, &'static str> {
Ok(match s {
"text" => OutputFormat::Text,
"json" => OutputFormat::Json,
_ => return Err("invalid output format"),
})
}
}

pub fn check_list(cfg: CheckListOptions) -> Result<()> {
let checks = crate::internal::check::all_checks();

if cfg.json {
if matches!(cfg.output, OutputFormat::Json) {
arsing marked this conversation as resolved.
Show resolved Hide resolved
let mut output = CheckListOutput::new();
for (section_name, section_checks) in checks {
output.insert(
Expand Down