hawk_cli/
cli.rs

1use clap::Parser;
2
3#[derive(Parser, Debug, Clone)]
4pub struct CopyFlags {
5    /// Watch for changes
6    #[clap(short, long, value_parser, default_value_t = false)]
7    pub watch: bool,
8}
9
10#[derive(Parser, Clone, Debug)]
11pub struct InitFlags {
12    /// Use json instead of yaml
13    #[clap(short, long, value_parser, default_value_t = false)]
14    pub json: bool,
15
16    /// Generate from local `pnpm-workspace` or package.json `workspaces` key.
17    #[clap(short, long, value_parser, default_value_t = false)]
18    pub read_env: bool,
19
20    /// Workflows directory path (Default: .github/workflows)
21    #[clap(long, value_parser)]
22    pub workflows: Option<String>,
23}
24
25#[derive(clap::Subcommand, Clone, Debug)]
26pub enum Action {
27    /// Delete generated files
28    Clean,
29
30    /// Initialize a repository.
31    Init(InitFlags),
32
33    /// Copy files to the `target` directory
34    Copy,
35
36    /// List workflows in the `target` directory
37    List,
38}
39
40#[derive(Parser, Clone, Debug)]
41#[clap(author, version, about, name = "hawk")]
42pub struct Args {
43    /// Specify the config file path
44    #[clap(short, global = true, long, value_parser, value_hint = clap::ValueHint::FilePath)]
45    pub config: Option<String>,
46
47    #[clap(subcommand)]
48    pub action: Option<Action>,
49
50    /// Specify which workspaces files copy / watch
51    /// Usage: --scope <workspace-name>
52    #[clap(long, value_parser, global = true)]
53    pub scope: Option<String>,
54
55    #[clap(global = true, short, long, value_parser, default_value_t = false)]
56    pub watch: bool,
57}