cuddle_please_misc/
args.rs

1use std::sync::{Arc, Mutex};
2
3use clap::{Args, ValueEnum};
4
5pub type StdinFn = Option<Arc<Mutex<dyn Fn() -> anyhow::Result<String> + Send + Sync + 'static>>>;
6
7#[derive(Args)]
8pub struct GlobalArgs {
9    /// token is the personal access token from gitea.
10    #[arg(
11        env = "CUDDLE_PLEASE_TOKEN",
12        long,
13        long_help = "token is the personal access token from gitea. It requires at least repository write access,  it isn't required by default, but for most usecases the flow will fail without it",
14        global = true,
15        help_heading = "Global"
16    )]
17    pub token: Option<String>,
18
19    /// whether to run in dry run mode (i.e. no pushes or releases)
20    #[arg(long, global = true, help_heading = "Global")]
21    pub dry_run: bool,
22
23    /// Inject configuration from stdin
24    #[arg(
25        env = "CUDDLE_PLEASE_CONFIG_STDIN",
26        long,
27        global = true,
28        help_heading = "Global",
29        long_help = "inject via stdin
30cat <<EOF | cuddle-please --config-stdin 
31something
32something
33something
34EOF
35config-stdin will consume stdin until the channel is closed via. EOF"
36    )]
37    pub config_stdin: bool,
38
39    #[arg(
40        env = "CUDDLE_PLEASE_NO_VCS",
41        long,
42        global = true,
43        help_heading = "Global"
44    )]
45    pub no_vcs: bool,
46
47    #[arg(
48        env = "CUDDLE_PLEASE_ENGINE",
49        long,
50        global = true,
51        help_heading = "Global",
52        default_value = "gitea"
53    )]
54    pub engine: RemoteEngine,
55
56    #[arg(
57        env = "CUDDLE_PLEASE_LOG_LEVEL",
58        long,
59        global = true,
60        help_heading = "Global",
61        default_value = "none"
62    )]
63    pub log_level: LogLevel,
64}
65
66#[derive(ValueEnum, Clone, Debug)]
67pub enum RemoteEngine {
68    Local,
69    Gitea,
70}
71#[derive(ValueEnum, Clone, Debug)]
72pub enum LogLevel {
73    None,
74    Trace,
75    Debug,
76    Info,
77    Error,
78}