Giter Site home page Giter Site logo

easyconf's Introduction

Easyconf

A config library for clojure program.

  • 2012-4-17 Release 0.1.1

Usage

  1. add to dependencies section of porject.clj

     [easyconf "0.1.1"]
  2. Define variables that can be configured at runtime under easyconf.core namespace, using macros defconf or defnconf. These two macro just like def and defn.

     (defconf ^{:validator string? :validator-msg "configure value must be
        string" :conf-name "conf-string" } conf-item "default value"}
    
     (defnconf game-name [game] (str "game name : " game))
  3. Optional meta-data Meta :validator :validator-msg :conf-name are optional.

    • :validator => A predict function which has one argument for the value of the item.
    • :validator-msg => The message which will print when an illegal value provided for the item.
    • :conf-name => ??
  4. In config file, you can redefine the value of configuable item.

     (config :conf-string "changed config value")
     (config-once :conf-string "changed config value")
    
     ;;the code below will trigger a exception
     (config-once :conf-string "change config value twice")  

Recommondation

Supply all the config value in a seperated namespace.

  (ns config.autoload
   (:use [easyconf.core]))

  (config-once :conf-1 "conf-1")
  (config-once :conf-two "conf-two")
  (config-once :game-name (fn [id] (get {"ddz" "doudizhu"} id)))

Checking

Function easyconf.confs/check checks if all the config value be used. You should invoke this function after the bootstrap of the program.

easyconf's People

Contributors

zhuangxm avatar sukuizhang avatar robertluo avatar

Stargazers

 avatar

Watchers

 avatar James Cloos avatar

easyconf's Issues

Check duplicate defconf at runtime

Find a way to check duplicate defconf at runtime.

For example:

1 add a function at the head of config file to enable check whether defconf is duplicated.

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.