Giter Site home page Giter Site logo

cprop cannot handle setting nils about cprop HOT 2 OPEN

tolitius avatar tolitius commented on July 18, 2024
cprop cannot handle setting nils

from cprop.

Comments (2)

tolitius avatar tolitius commented on July 18, 2024

the reason for str->value to front the Clojure reader is because not all configuration and properties come from edn like in your table above. Some of them, quite often, come from ENV, system properties or configuration managers (e.g. Consul).

In those cases types are not as clear. For example, let's look at overriding a "username":

=> (require '[cprop.core :as cp])
=> (cp/load-config)
{:datomic ...
 :source
 {:account
  {:rabbit
   {...
    :username "guest"}}}
=> (System/setProperty "source_account_rabbit_username" "0x42")

with the way code is written now:

=> (cp/load-config)
{:datomic ...
 :source
 {:account
  {:rabbit
   {...
    :username "0x42"}}}

relying on Clojure reader (i.e. removing "these lines"):

=> (cp/load-config)
{:datomic ...
 :source
 {:account
  {:rabbit
   {...
     :username 66}}}

I added better comments and a test so it clarifies things a bit

from cprop.

bn-darindouglass-zz avatar bn-darindouglass-zz commented on July 18, 2024

Thanks for the quick turn-around!

Yeah there’s definitely some overlap where things can be parsed oddly; though I think the times where the reader would mis-parse something would be the vast minority situations.

Anyway, my original intent was lost among my thoughts on the use of the reader: you cannot nil a setting, it’ll be set to “nil” instead. A simple (= “nil” v) before the alpha number regex should fix the use case.

from cprop.

Related Issues (20)

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.