(defkey the-sym arg-vec & more)
Define one or more keys as vars using argument vectors. Every argument vector must have one of the following arities:
[key]
[key options]
[key validator description]
[key validator description options]
See make-key
for details. First argument to defkey
can optionally be a base option-map for all argument vectors.
Examples:
(defkey
ip [:ip-address]
port [:port #(< 1023 % 65535) "Server port" {:parser str->int :default 3000}])
(defkey
{:lookup lookup-key}
ip ["server.ip.address"]
port ["server.port" #(< 1023 % 65535) "Server port" {:parser str->int :default 3000}])
See: make-key
Define one or more keys as vars using argument vectors. Every argument vector must have one of the following arities: [key] [key options] [key validator description] [key validator description options] See `make-key` for details. First argument to `defkey` can optionally be a base option-map for all argument vectors. Examples: (defkey ip [:ip-address] port [:port #(< 1023 % 65535) "Server port" {:parser str->int :default 3000}]) (defkey {:lookup lookup-key} ip ["server.ip.address"] port ["server.port" #(< 1023 % 65535) "Server port" {:parser str->int :default 3000}]) See: make-key
(letval bindings & body)
Like let, except in which the left hand side is a destructuring map, right hand side is the argument to key finder. Beside symbols, the destructuring map optionally supports :defs (symbols bound to key finders) and :as keys. Example: (letval [{:defs [foo bar] ; foo, bar are key finders baz baz-key ; baz-key is a key finder :as m} {:foo 10 :bar 20 :baz 30}] ;; foo, bar and baz are now bound to values looked up in the map ...)
Like let, except in which the left hand side is a destructuring map, right hand side is the argument to key finder. Beside symbols, the destructuring map optionally supports :defs (symbols bound to key finders) and :as keys. Example: (letval [{:defs [foo bar] ; foo, bar are key finders baz baz-key ; baz-key is a key finder :as m} {:foo 10 :bar 20 :baz 30}] ;; foo, bar and baz are now bound to values looked up in the map ...)
(lookup-key the-map
the-key
validator
description
value-parser
default-value?
default-value
not-found)
Look up a key in a map or something that implements clojure.lang.ILookup.
Look up a key in a map or something that implements clojure.lang.ILookup.
(lookup-keypath the-map
ks
validator
description
value-parser
default-value?
default-value
not-found)
Look up a key path in a map or something that implements clojure.lang.ILookup.
Look up a key path in a map or something that implements clojure.lang.ILookup.
(make-key the-key
validator
description
{:keys [lookup parser default sysprop envvar source]
:or {lookup lookup-key parser i/identity-parser}
:as options})
Create a key that can be looked up in a java.util.Map/Properties or clojure.lang.ILookup (map, vector) instance. The following optional keys are supported: :lookup - The function to look the key up: (fn [the-map the-key validator description value-parser default-value? default-value (fn not-found-fn [not-found-message])]) default: ordinary key look up :parser - The value parser function (args: key, value) :default - Default value to return if key is not found :sysprop - System property name that can override the config value (before parsing) :envvar - Environment variable that can override the config value and system property (before parsing) :source - Source or container (of reference type, e.g. atom/promise etc.) of key/value pairs
Create a key that can be looked up in a java.util.Map/Properties or clojure.lang.ILookup (map, vector) instance. The following optional keys are supported: :lookup - The function to look the key up: (fn [the-map the-key validator description value-parser default-value? default-value (fn not-found-fn [not-found-message])]) default: ordinary key look up :parser - The value parser function (args: key, value) :default - Default value to return if key is not found :sysprop - System property name that can override the config value (before parsing) :envvar - Environment variable that can override the config value and system property (before parsing) :source - Source or container (of reference type, e.g. atom/promise etc.) of key/value pairs
Reader/writer for properties files.
Reader/writer for properties files.
(read-config config-filenames)
(read-config config-filenames
{:keys [parent-key logger config-readers media-readers realize?]
:or {parent-key "parent.filenames"
logger u/default-logger
config-readers [property-file-io edn-file-io]
realize? true}
:as options})
Read config file(s) returning a java.util.Map instance. Options: :parent-key (string) key to identify the parent filenames having K/V pairs, default: "parent.filenames" :logger (object) instance of keypin.Logger, defaults to printing to err :config-readers (list/vec) collection of keypin.ConfigIO instances, default: for Properties and EDN files :media-readers (list/vec) collection of keypin.MediaReader instances, default: for Filesystem and Classpath :realize? (boolean) whether realize the template variables in the string, default: true
Read config file(s) returning a java.util.Map instance. Options: :parent-key (string) key to identify the parent filenames having K/V pairs, default: "parent.filenames" :logger (object) instance of keypin.Logger, defaults to printing to *err* :config-readers (list/vec) collection of keypin.ConfigIO instances, default: for Properties and EDN files :media-readers (list/vec) collection of keypin.MediaReader instances, default: for Filesystem and Classpath :realize? (boolean) whether realize the template variables in the string, default: true
(realize-config config)
(realize-config config
{:keys [logger config-mapper]
:or {logger u/default-logger config-mapper Mapper/DEFAULT}
:as options})
Realize config by applying variable substitution, if any. Options: :logger (object) instance of keypin.Logger, defaults to printing to err :config-mapper (object) instance of keypin.Mapper, default: keypin.Mapper/DEFAULT
Realize config by applying variable substitution, if any. Options: :logger (object) instance of keypin.Logger, defaults to printing to *err* :config-mapper (object) instance of keypin.Mapper, default: keypin.Mapper/DEFAULT
(write-config config-filename config)
(write-config config-filename
config
{:keys [logger config-writers escape?]
:or {logger u/default-logger
config-writers [property-file-io edn-file-io]
escape? true}
:as options})
Write config to a specified file. Options: :logger (object) instance of keypin.Logger, defaults to printing to err :config-writers (list/vec) collection of keypin.ConfigIO instances, default: for Properties and EDN files :escape? (boolean) whether escape values when writing, default: true
Write config to a specified file. Options: :logger (object) instance of keypin.Logger, defaults to printing to *err* :config-writers (list/vec) collection of keypin.ConfigIO instances, default: for Properties and EDN files :escape? (boolean) whether escape values when writing, default: true
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close