cuddle-please/crates/cuddle-please-misc/src/args.rs
kjuulh b4acb55d0c
feat: hack get in control of log level
I haven't found a good way of enabling all of mine, but disabling all of theirs.
as such right now it is a deny list, where some entries reqwest,cliff,hyper is set to
error, and our own is controlled via.

Signed-off-by: kjuulh <contact@kjuulh.io>
2023-08-02 00:13:34 +02:00

79 lines
1.8 KiB
Rust

use std::sync::{Arc, Mutex};
use clap::{Args, ValueEnum};
pub type StdinFn = Option<Arc<Mutex<dyn Fn() -> anyhow::Result<String> + Send + Sync + 'static>>>;
#[derive(Args)]
pub struct GlobalArgs {
/// token is the personal access token from gitea.
#[arg(
env = "CUDDLE_PLEASE_TOKEN",
long,
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",
global = true,
help_heading = "Global"
)]
pub token: Option<String>,
/// whether to run in dry run mode (i.e. no pushes or releases)
#[arg(long, global = true, help_heading = "Global")]
pub dry_run: bool,
/// Inject configuration from stdin
#[arg(
env = "CUDDLE_PLEASE_CONFIG_STDIN",
long,
global = true,
help_heading = "Global",
long_help = "inject via stdin
cat <<EOF | cuddle-please --config-stdin
something
something
something
EOF
config-stdin will consume stdin until the channel is closed via. EOF"
)]
pub config_stdin: bool,
#[arg(
env = "CUDDLE_PLEASE_NO_VCS",
long,
global = true,
help_heading = "Global"
)]
pub no_vcs: bool,
#[arg(
env = "CUDDLE_PLEASE_ENGINE",
long,
global = true,
help_heading = "Global",
default_value = "gitea"
)]
pub engine: RemoteEngine,
#[arg(
env = "CUDDLE_PLEASE_LOG_LEVEL",
long,
global = true,
help_heading = "Global",
default_value = "none"
)]
pub log_level: LogLevel,
}
#[derive(ValueEnum, Clone, Debug)]
pub enum RemoteEngine {
Local,
Gitea,
}
#[derive(ValueEnum, Clone, Debug)]
pub enum LogLevel {
None,
Trace,
Debug,
Info,
Error,
}