Giter VIP home page Giter VIP logo

macro_env's Introduction

Macro_env: An environment variable seeking crate

Macro_env is a crate to find environment variables.
Originally designed to easily fetch environment variables from different places without having to change a lot of different code.
By simply changing the SearchType in the macro or in the function, it fetches the variable from a different location.

Usage

First add:

[dependencies]
macro_env = "0.1.*"

Macro

// Import the crate, importing the whole crate is the easiest
// You can also manually import the function you need, for .env search for example:
// `use macro_env::{dotenvreader, macro_env};`
use macro_env::*;

// Fetch the environment variable "OS" from the .env file at the cargo.toml level
macro_env!(File, "OS");

// Fetch the environment variable "OS" from the system environment variables
macro_env!(System, "OS");

// Asks the user for enter the input through the terminal
macro_env!(Input);

// All, without specifying the searchtype, will try to find the variable through all 3 methods:
// First it checks for a .env file
// Then by searching for a system variable
// And if both fail, it will ask the user for input
macro_env!(All, "OS");
macro_env!("OS");

EnvSeeker()

use macro_env::*;
use macro_env::SearchType::*;
// You can use envseeker() when you prefer using a function over a macro
envseeker(Envfile, "OS")

macro_env's People

Contributors

keiveulbugs avatar

Watchers

 avatar

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.