Skip to content

Commit

Permalink
Merge pull request #15 from dariocurr/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
dariocurr committed Sep 18, 2023
2 parents 13e6a21 + 4b9f16c commit 844ec4f
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 8 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ jobs:
- name: Release Rust library
run: cargo release --execute --no-confirm --tag-prefix "" --unpublished

- name: Setup git
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions@users.noreply.github.com"
- name: Output tag
id: tag
run: echo "tag=$(git describe --tags --abbrev=0)" >> $GITHUB_OUTPUT
Expand Down
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# Env Settings

<p align="center">
<img src="./docs/logo.svg" alt="Env Settings" width="128" height="128">
</p>

<div align="center">

<a href="https://crates.io/crates/env-settings">![crates](https://img.shields.io/crates/v/env-settings.svg)</a>
<a href="https://github.com/dariocurr/env-settings/blob/main/Cargo.toml#L29">![license](https://img.shields.io/crates/l/env-settings)</a>
<a href="https://github.com/dariocurr/env-settings/actions/workflows/validate.yml">![validate](https://github.com/dariocurr/env-settings/actions/workflows/validate.yml/badge.svg)</a>

</div>

**Env Settings** is a Rust library that helps you to initialize structs using environment variables

> This Rust library took inspiration from [`pydantic's BaseSettings`](https://docs.pydantic.dev/latest/usage/pydantic_settings/) Python class
Expand All @@ -13,7 +25,7 @@ cargo add env-settings-derive

## Usage

When you add the `EnvSettings` derive to a `struct`, two methods are added to it
When you add the `EnvSettings` derive to a `struct`, two public methods are added to it

- ```rust
fn from_env(...) -> env_settings_utils::EnvSettingsResult<Self>
Expand Down
2 changes: 1 addition & 1 deletion docs/logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion env-settings-derive/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ version.workspace = true
proc-macro = true

[dependencies]
env-settings-utils = { path = "./../env-settings-utils", version = "0.1" }
env-settings-utils = "0.1"
proc-macro2 = "1.0"
quote = "1.0"
syn = "2.0"
Expand Down
4 changes: 2 additions & 2 deletions env-settings-derive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,15 +172,15 @@ fn implement(input: &utils::input::EnvSettingsInput) -> TokenStream {

impl #struct_name {

fn new(#(#new_args),*) -> env_settings_utils::EnvSettingsResult<Self> {
pub fn new(#(#new_args),*) -> env_settings_utils::EnvSettingsResult<Self> {
#pre_impls
let instance = Self {
#(#new_impls),*
};
Ok(instance)
}

fn from_env(#(#from_env_args),*) -> env_settings_utils::EnvSettingsResult<Self> {
pub fn from_env(#(#from_env_args),*) -> env_settings_utils::EnvSettingsResult<Self> {
#pre_impls
let instance = Self {
#(#from_env_impls),*
Expand Down
2 changes: 2 additions & 0 deletions env-settings-utils/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ pub enum EnvSettingsError {
NotExists(&'static str),
}

impl error::Error for EnvSettingsError {}

impl fmt::Display for EnvSettingsError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Expand Down
4 changes: 2 additions & 2 deletions env-settings/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ repository.workspace = true
version.workspace = true

[dev-dependencies]
env-settings-utils = { path = "./../env-settings-utils", version = "0.1" }
env-settings-derive = { path = "./../env-settings-derive", version = "0.1" }
env-settings-utils = "0.1"
env-settings-derive = "0.1"
2 changes: 1 addition & 1 deletion env-settings/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
//!
//! ## Usage
//!
//! When you add the `EnvSettings` derive to a `struct`, two methods are added to it
//! When you add the `EnvSettings` derive to a `struct`, two public methods are added to it
//!
//! ```ignore
//! fn from_env(...) -> env_settings_utils::EnvSettingsResult<Self>
Expand Down

0 comments on commit 844ec4f

Please sign in to comment.