Coder Social home page Coder Social logo

configure's People

Contributors

killercup avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

configure's Issues

Allow global, unprefixed names

First of all thanks for this crate, I like it!

The scoping of environment variable names by the name of the struct implementing Configure is nice in general, but sometimes I want to extract unscoped, global environment variables to use for configuration.

For example it would be convenient to be able to use the same DATABASE_URL env variable as the diesel cli. What already works is to add a #[configure(name = "")] annotation to the struct, but then all fields are unscoped.

A straightforward way to implement this would be a new annotation, maybe something like no_prefix:

#[derive(Deserialize, Debug, Configure)]
struct MyAppName {
    host: String, // would be MY_APP_NAME_HOST
    #[configure(no_prefix)]
    database_url: String, // just DATABASE_URL
}

I mainly have environment variables as a source in mind, but I can imagine this working in other contexts.

If I manage to free up some time I would be willing to document the existing way if there is one, or to implement the new option :)

Example

How do I use configure in my project?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.