Compare commits

...

2 Commits

Author SHA1 Message Date
8dc577c725 Update docs 2025-05-22 19:24:11 +02:00
ca8f4aecb1 Change metadata 2025-05-19 21:55:47 +02:00
7 changed files with 53 additions and 7 deletions

2
Cargo.lock generated
View File

@@ -4,4 +4,4 @@ version = 4
[[package]] [[package]]
name = "merlin_env_helper" name = "merlin_env_helper"
version = "0.1.0" version = "0.2.0"

View File

@@ -1,6 +1,9 @@
[package] [package]
name = "merlin_env_helper" name = "merlin_env_helper"
version = "0.1.0" version = "0.2.0"
edition = "2024" edition = "2024"
publish = ["mycargo"]
description = "Utility functions to read environment with fallback and values from a file"
license = "MIT"
repository = "ssh://git@gitea.merlinserver.de:2222/Stefan/merlin_env_helper.git"
[dependencies] [dependencies]

View File

@@ -1 +1,5 @@
# NO Man Sky Wiki # MERLIN ENV HELPER
merlin_env_helper
Helper lib to use environment variables. Like docker with fallback an value maybe in a file.

View File

@@ -21,8 +21,8 @@
//! # Examples //! # Examples
//! //!
//! ```rust //! ```rust
//! use no_man_sky::config::EnvKey; //! use merlin_env_helper::config::EnvKey;
//! use no_man_sky::config::get_env_value; //! use merlin_env_helper::config::get_env_value;
//! let env_key = EnvKey::key("MY_CONFIG_KEY"); //! let env_key = EnvKey::key("MY_CONFIG_KEY");
//! match get_env_value(&env_key) { //! match get_env_value(&env_key) {
//! Ok(value) => println!("Config value: {}", value), //! Ok(value) => println!("Config value: {}", value),

View File

@@ -1,3 +1,12 @@
//! This module serves as the configuration layer for the application.
//!
//! It is divided into submodules:
//! - `env`: Handles environment-specific configuration, such as reading
//! environment variables or setting up runtime parameters.
//! - `types`: Defines shared types and structures used for configuration.
//!
//! The module re-exports items from its submodules for easier access.
pub mod env; pub mod env;
pub mod types; pub mod types;

View File

@@ -1,3 +1,26 @@
/// Represents an environment key with optional secondary key and fallback value.
///
/// This struct is used to define keys for environment variables, with support for
/// optional secondary keys and fallback values.
///
/// # Fields
/// - `key`: The primary key as a `String`.
/// - `sec_key`: An optional secondary key as a `String`.
/// - `fallback`: An optional fallback value as a `String`.
///
/// # Methods
/// - `EnvKey::key(key: &str) -> Self`
/// Creates a new `EnvKey` with the given primary key and no secondary key or fallback value.
///
/// - `EnvKey::key_with_fallback(key: &str, fallback: &str) -> Self`
/// Creates a new `EnvKey` with the given primary key and fallback value, but no secondary key.
///
/// - `EnvKey::secure_key(key: &str, sec_key: &str) -> Self`
/// Creates a new `EnvKey` with the given primary key and secondary key, but no fallback value.
///
/// - `EnvKey::secure_with_fallback(key: &str, sec_key: &str, fallback: &str) -> Self`
/// Creates a new `EnvKey` with the given primary key, secondary key, and fallback value.
#[derive(Debug, PartialEq, Eq)] #[derive(Debug, PartialEq, Eq)]
pub struct EnvKey { pub struct EnvKey {
pub key: String, pub key: String,

View File

@@ -1 +1,8 @@
pub mod config;
/// This module declaration makes the `config` module public, allowing its items to be accessed
/// from outside the current crate. The `pub use config::*;` statement re-exports all public
/// items from the `config` module, making them directly accessible from the root of the crate.
pub mod config;
pub use config::*;