github_workflows_update/
cli.rs1use clap::Parser;
6use clap::ValueEnum;
7
8#[derive(Parser, Debug)]
9#[command(
10 author,
11 version,
12 about = "Check github workflows for actions that can be updated",
13 long_about = "github-workflows-update reads all github workflow and checks the latest
14available versions of all github actions and workflow dispatches used, showing
15which ones can be updated and optionally updating them automatically."
16)]
17pub struct Cli {
18 #[clap(short = 'n', long = "dry-run")]
20 pub dryrun: bool,
21 #[clap(short = 'f', long, value_enum, value_parser)]
23 pub output_format: Option<OutputFormat>,
24 #[clap(long)]
26 pub error_on_outdated: bool,
27}
28
29#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, ValueEnum, Default, Debug)]
30pub enum OutputFormat {
31 #[default]
32 Standard,
33 GithubWarning,
35}
36
37#[cfg(test)]
38mod tests {
39 use super::*;
40 use clap::CommandFactory;
41
42 #[test]
43 fn test_cli() {
44 Cli::command().debug_assert();
45 }
46
47 #[test]
48 fn test_parse_args() {
49 let args = Cli::parse_from(&["test", "-n", "-f", "github-warning", "--error-on-outdated"]);
50 assert!(args.dryrun);
51 assert_eq!(args.output_format, Some(OutputFormat::GithubWarning));
52 assert!(args.error_on_outdated);
53 }
54}