1
Fork 0
mirror of https://github.com/Steffo99/patched-porobot.git synced 2024-10-16 09:37:27 +00:00

Start work on updating micronfig

This commit is contained in:
Steffo 2023-06-22 19:10:54 +02:00
parent d86efd6362
commit 4c9beea15f
Signed by: steffo
GPG key ID: 2A24051445686895
3 changed files with 43 additions and 46 deletions

7
Cargo.lock generated
View file

@ -992,9 +992,12 @@ dependencies = [
[[package]]
name = "micronfig"
version = "0.1.2"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "09d5fa5735feed9ff4d6fc550793ef80d18b90f33f3f89af6176318f295383cd"
checksum = "caf3c1187adebdc5ad8ca94618b966fe8f40e4a3c80fa2f3eaee47891b410156"
dependencies = [
"lazy_static",
]
[[package]]
name = "mime"

View file

@ -33,7 +33,7 @@ hmac = { version = "0.12.1", optional = true }
sha2 = { version = "0.10.6", optional = true }
# exec
pretty_env_logger = { version = "0.4.0", optional = true }
micronfig = { version = "0.1.2", optional = true }
micronfig = { version = "0.2.0", optional = true }
# data
serde = { version = "1.0.140", features = ["derive"] }
serde_json = { version = "1.0.82" }

View file

@ -5,7 +5,7 @@
/// Configuration required by the `exec` feature.
#[cfg(feature = "exec")]
pub mod exec {
lazy_static::lazy_static! {
/// The locale that card data should be downloaded in.
///
/// # Examples
@ -13,8 +13,7 @@ pub mod exec {
/// - `en_US`
/// - `it_IT`
///
pub static ref DATA_DRAGON_LOCALE: String =
micronfig::required("DATA_DRAGON_LOCALE");
micronfig::required!(DATA_DRAGON_LOCALE, String);
/// The set codes for which card data should be downloaded, separated by commas.
///
@ -24,42 +23,37 @@ pub mod exec {
/// - `set1`
/// - `set1,set2,set3,set4,set5,set6,set6cde,set7`
///
pub static ref DATA_DRAGON_SET_CODES: Vec<String> =
micronfig::required::<String>("DATA_DRAGON_SET_CODES")
.split(",").map(|s: &str| s.to_string()).collect();
}
micronfig::required!(DATA_DRAGON_SET_CODES, String);
}
/// Configuration required by the `jpg` feature.
#[cfg(feature = "jpg")]
pub mod jpg {
lazy_static::lazy_static! {
/// Secret key configured in imgproxy.
pub static ref POROXY_KEY: Vec<u8> = micronfig::required("POROXY_KEY");
micronfig::required!(POROXY_KEY, Vec<u8>);
/// Salt configured in imgproxy.
pub static ref POROXY_SALT: String = micronfig::required("POROXY_SALT");
micronfig::required!(POROXY_SALT, String);
/// URL where imgproxy can be reached at.
pub static ref POROXY_HOST: String = micronfig::required("POROXY_HOST");
}
micronfig::required!(POROXY_HOST, String);
}
/// Configuration required by the `discord` feature.
#[cfg(feature = "discord")]
pub mod discord {
lazy_static::lazy_static! {
/// ID of the guild where commands should be registered in.
///
/// If not defined, commands are registered globally, and then cached.
///
/// Useful for development, since guild commands are not cached.
pub static ref SERENITY_DEV_GUILD_ID: Option<serenity::model::id::GuildId> = micronfig::optional("SERENITY_DEV_GUILD_ID").map(|s: u64| s.into());
micronfig::optional!(SERENITY_DEV_GUILD_ID, serenity::model::id::GuildId);
/// The Discord bot token.
pub static ref SERENITY_TOKEN: String = micronfig::required("SERENITY_TOKEN");
micronfig::required!(SERENITY_TOKEN, String);
/// The Discord bot app ID.
pub static ref SERENITY_APPID: u64 = micronfig::required("SERENITY_APPID");
}
micronfig::required!(SERENITY_APPID, u64);
}