action_validator/
config.rs1use clap::Parser;
2use serde::Serialize;
3use std::path::PathBuf;
4
5#[derive(Parser, Debug)]
6#[command(
7 name = "action-validator",
8 about = "A validator for GitHub Action and Workflow YAML files",
9 version
10)]
11pub struct CliConfig {
12 #[arg(short, long)]
14 pub verbose: bool,
15
16 #[arg(
17 long,
18 help = "Use specified dir as root of glob matching, rather than the current directory"
19 )]
20 pub rootdir: Option<PathBuf>,
21
22 #[arg(name = "path_to_action_yaml")]
24 pub src: Vec<PathBuf>,
25}
26
27#[derive(Serialize, Copy, Clone, Debug)]
28pub enum ActionType {
29 #[serde(rename = "action")]
30 Action,
31 #[serde(rename = "workflow")]
32 Workflow,
33}
34
35pub struct JsConfig<'a> {
36 pub action_type: ActionType,
37 pub src: &'a str,
38 pub verbose: bool,
39}
40
41pub struct RunConfig<'a> {
42 pub file_path: Option<&'a str>,
43 pub file_name: Option<&'a str>,
44 pub action_type: ActionType,
45 pub src: &'a str,
46 pub verbose: bool,
47 pub rootdir: Option<PathBuf>,
48}
49
50impl<'a> From<&JsConfig<'a>> for RunConfig<'a> {
51 fn from(config: &JsConfig<'a>) -> Self {
52 RunConfig {
53 file_path: None,
54 file_name: None,
55 action_type: config.action_type,
56 src: config.src,
57 verbose: config.verbose,
58 rootdir: None,
59 }
60 }
61}