use clap::Parser;
use clap::ValueEnum;
#[derive(Parser, Debug)]
#[command(
author,
version,
about = "Check github workflows for actions that can be updated",
long_about = "github-workflows-update reads all github workflow and checks the latest
available versions of all github actions and workflow dispatches used, showing
which ones can be updated and optionally updating them automatically."
)]
pub struct Cli {
#[clap(short = 'n', long = "dry-run")]
pub dryrun: bool,
#[clap(short = 'f', long, value_enum, value_parser)]
pub output_format: Option<OutputFormat>,
#[clap(long)]
pub error_on_outdated: bool,
}
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, ValueEnum, Default, Debug)]
pub enum OutputFormat {
#[default]
Standard,
GithubWarning,
}
#[cfg(test)]
mod tests {
use super::*;
use clap::CommandFactory;
#[test]
fn test_cli() {
Cli::command().debug_assert();
}
#[test]
fn test_parse_args() {
let args = Cli::parse_from(&["test", "-n", "-f", "github-warning", "--error-on-outdated"]);
assert!(args.dryrun);
assert_eq!(args.output_format, Some(OutputFormat::GithubWarning));
assert!(args.error_on_outdated);
}
}