Skip to content

Commit

Permalink
Update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
dariocurr committed Sep 19, 2023
1 parent 5eaaf7d commit acf555d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@
## Installation

```shell
cargo add env-settings
cargo add env-settings-derive
cargo add env-settings env-settings-derive env-settings-utils
```

## Usage
Expand All @@ -31,13 +30,13 @@ When you add the `EnvSettings` derive to a `struct`, two public methods are adde
fn from_env(...) -> env_settings_utils::EnvSettingsResult<Self>
```

It creates a new instance using just the environment variables. If something fails, it returns an `env_settings_utils::EnvSettingsError` error
Create a new instance using just the environment variables. Skipped fields must be passed. If something fails, it returns an `env_settings_utils::EnvSettingsError` error

- ```rust
fn new(...) -> env_settings_utils::EnvSettingsResult<Self>
```

It creates a new instance using a combination of environment variables and parameters. More in detail, every field value can be passed as parameter wrapped in an `Option` object. Then if the parameter is `Some`, it is used, otherwise the value is recoved from the environment variables. If something fails, it returns an `env_settings_utils::EnvSettingsError` error
Create a new instance using a combination of environment variables and parameters. More in detail, every field that can be initialized by the environment variables can be passed as parameter wrapped in an `Option` object. Then if the parameter is `Some`, it is used, otherwise the value is recoved from the environment variables. Skipped fields must be passed. If something fails, it returns an `env_settings_utils::EnvSettingsError` error

### Basic

Expand Down
7 changes: 7 additions & 0 deletions env-settings-derive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,8 @@ fn implement(input: &utils::input::EnvSettingsInput) -> TokenStream {

impl #struct_name {

/// Create a new instance using just the environment variables. Skipped fields must be passed.
/// If something fails, it returns an `env_settings_utils::EnvSettingsError` error
pub fn new(#(#new_args),*) -> env_settings_utils::EnvSettingsResult<Self> {
#pre_impls
let instance = Self {
Expand All @@ -180,6 +182,11 @@ fn implement(input: &utils::input::EnvSettingsInput) -> TokenStream {
Ok(instance)
}

/// Create a new instance using a combination of environment variables and parameters.
/// More in detail, every field that can be initialized by the environment variables can be passed
/// as parameter wrapped in an `Option` object. Then if the parameter is `Some`, it is used,
/// otherwise the value is recoved from the environment variables. Skipped fields must be passed.
/// If something fails, it returns an `env_settings_utils::EnvSettingsError` error
pub fn from_env(#(#from_env_args),*) -> env_settings_utils::EnvSettingsResult<Self> {
#pre_impls
let instance = Self {
Expand Down
12 changes: 8 additions & 4 deletions env-settings/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
//! ## Installation
//!
//! ```bash
//! cargo add env-settings
//! cargo add env-settings-derive
//! cargo add env-settings env-settings-derive env-settings-utils
//! ```
//!
//! ## Usage
Expand All @@ -26,13 +25,18 @@
//! fn from_env(...) -> env_settings_utils::EnvSettingsResult<Self>
//! ```
//!
//! It creates a new instance using just the environment variables. If something fails, it returns an `env_settings_utils::EnvSettingsError` error
//! It creates a new instance using just the environment variables. Skipped fields must be passed.
//| If something fails, it returns an `env_settings_utils::EnvSettingsError` error
//!
//! ```ignore
//! fn new(...) -> env_settings_utils::EnvSettingsResult<Self>
//! ```
//!
//! It creates a new instance using a combination of environment variables and parameters. More in detail, every field value can be passed as parameter wrapped in an `Option` object. Then if the parameter is `Some`, it is used, otherwise the value is recoved from the environment variables. If something fails, it returns an `env_settings_utils::EnvSettingsError` error
//! It creates a new instance using a combination of environment variables and parameters.
//! More in detail, every field that can be initialized by the environment variables can be passed as
//! parameter wrapped in an `Option` object. Then if the parameter is `Some`, it is used,
//! otherwise the value is recoved from the environment variables. Skipped fields must be passed.
//! If something fails, it returns an `env_settings_utils::EnvSettingsError` error
//!
//! ### Basic
//!
Expand Down

0 comments on commit acf555d

Please sign in to comment.