Finish refactoring
This commit is contained in:
+45
@@ -1,5 +1,50 @@
|
||||
#[derive(clap::Parser)]
|
||||
pub struct Args {
|
||||
/// The Discord bot token to run the bot with.
|
||||
#[arg(env = "PAYPHONE_TOKEN")]
|
||||
pub token: String,
|
||||
|
||||
#[arg(
|
||||
long,
|
||||
short,
|
||||
value_enum,
|
||||
default_value_t = LevelFilter::Info,
|
||||
env = "PAYPHONE_LOGGING",
|
||||
value_name = "LEVEL",
|
||||
long_help = "The minimum level logs have to be to be outputted into the console, or off for no logs."
|
||||
)]
|
||||
pub logging: LevelFilter,
|
||||
|
||||
#[arg(
|
||||
long,
|
||||
short,
|
||||
env = "PAYPHONE_DATABASE_URL",
|
||||
value_name = "URL",
|
||||
default_value_t = String::from("127.0.0.1:9042"))
|
||||
]
|
||||
pub database_url: String,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, clap::ValueEnum)]
|
||||
pub enum LevelFilter {
|
||||
Off,
|
||||
Trace,
|
||||
Debug,
|
||||
Info,
|
||||
Warn,
|
||||
Error,
|
||||
}
|
||||
|
||||
#[allow(clippy::from_over_into)]
|
||||
impl Into<log::LevelFilter> for LevelFilter {
|
||||
fn into(self) -> log::LevelFilter {
|
||||
match self {
|
||||
Self::Off => log::LevelFilter::Off,
|
||||
Self::Trace => log::LevelFilter::Trace,
|
||||
Self::Debug => log::LevelFilter::Debug,
|
||||
Self::Info => log::LevelFilter::Info,
|
||||
Self::Warn => log::LevelFilter::Warn,
|
||||
Self::Error => log::LevelFilter::Error,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user