Omniconf is an exhaustive configuration tool.
Omniconf is an exhaustive configuration tool.
The default data-readers to use when reading a configuration file
The default data-readers to use when reading a configuration file
(define scheme)
Declare the configuration that the program supports. scheme
is a map of
keyword names to specs.
Example:
(define {:boolean-option {:description "can be either true or nil"} :string-option {:type :string :description "this option's value is taken as is"} :integer-option {:type :number :required true :description "parsed as integer, must be present"}}
Supported attributes:
:description - string to describe the option in the help message. :type - one of #{:string :keyword :number :boolean :edn :file :directory}. :parser - 1-arity fn to be called on a string given by CMD args or ENV. Unnecessary if :type is specified. :required - boolean value whether the option must have a value; or 0-arity fn, if it returns true, the option must have a value. :one-of - a set of accepted values for the given option. :verifier - fn on key and val, should throw an exception if option is invalid. :secret - if true, value will not be printed during verification. :nested - allows to create hierarchies of options.
Declare the configuration that the program supports. `scheme` is a map of keyword names to specs. Example: (define {:boolean-option {:description "can be either true or nil"} :string-option {:type :string :description "this option's value is taken as is"} :integer-option {:type :number :required true :description "parsed as integer, must be present"}} Supported attributes: :description - string to describe the option in the help message. :type - one of #{:string :keyword :number :boolean :edn :file :directory}. :parser - 1-arity fn to be called on a string given by CMD args or ENV. Unnecessary if :type is specified. :required - boolean value whether the option must have a value; or 0-arity fn, if it returns true, the option must have a value. :one-of - a set of accepted values for the given option. :verifier - fn on key and val, should throw an exception if option is invalid. :secret - if true, value will not be printed during verification. :nested - allows to create hierarchies of options.
(enable-functions-as-defaults)
Allow invoking functions passed to :default field for the options.
Allow invoking functions passed to :default field for the options.
(fail fmt & args)
Throws an exception with a message specified by fmt
and args
.
Throws an exception with a message specified by `fmt` and `args`.
(get & ks)
Get the value from the current configuration given the path in nested
structure specified by ks
. Path can be provided as a single sequence, or as
a variable number of keywords.
Get the value from the current configuration given the path in nested structure specified by `ks`. Path can be provided as a single sequence, or as a variable number of keywords.
(parse-boolean s)
Parses string as a Boolean.
Parses string as a Boolean.
(parse-edn s)
Calls clojure.edn/read-string
on a string.
Calls `clojure.edn/read-string` on a string.
(parse-filename s)
Parses string as a relative filename.
Parses string as a relative filename.
(parse-number s)
Parses string as a Long.
Parses string as a Long.
(populate-from-cmd cmd-args)
(populate-from-cmd cmd-args quit-on-error)
Fill configuration from command-line arguments.
Fill configuration from command-line arguments.
(populate-from-env)
(populate-from-env quit-on-error)
Fill configuration from environment variables. This function must be called
only after define
. If quit-on-error
is true, immediately quit when program
occurs.
Fill configuration from environment variables. This function must be called only after `define`. If `quit-on-error` is true, immediately quit when program occurs.
(populate-from-file edn-file)
(populate-from-file edn-file quit-on-error)
Fill configuration from an edn file. Any data-reader functions may be optionally set by setting the data-readers binding.
Fill configuration from an edn file. Any data-reader functions may be optionally set by setting the *data-readers* binding.
(populate-from-map config-map)
Fill configuration from a map passed directly as value.
Fill configuration from a map passed directly as value.
(populate-from-properties)
(populate-from-properties quit-on-error)
Fill configuration from Java properties.
Fill configuration from Java properties.
(populate-from-ssm path)
Fill configuration from AWS Systems Manager. Recursively look up all parameters
under the given path
.
com.grammarly/omniconf.ssm dependency must be on classpath.
Fill configuration from AWS Systems Manager. Recursively look up all parameters under the given `path`. com.grammarly/omniconf.ssm dependency must be on classpath.
(populate-from-ssm-continually path interval-in-seconds)
Like populate-from-ssm
, but runs regularly at the specified interval. Use
this to dynamically reconfigure your program at runtime.
com.grammarly/omniconf.ssm dependency must be on classpath.
Like `populate-from-ssm`, but runs regularly at the specified interval. Use this to dynamically reconfigure your program at runtime. com.grammarly/omniconf.ssm dependency must be on classpath.
(print-cli-help)
Prints a help message describing all supported command-line arguments.
Prints a help message describing all supported command-line arguments.
(report-configuration)
Prints the current configuration state to *out*
. Hide options marked as
:secret
.
Prints the current configuration state to `*out*`. Hide options marked as `:secret`.
(set & args)
Set the value
for the ks
path in the current configuration. Path can be
provided as a single sequence, or as a variable number of keywords. If value
is a string, call the respective parser on it before setting.
Set the `value` for the `ks` path in the current configuration. Path can be provided as a single sequence, or as a variable number of keywords. If value is a string, call the respective parser on it before setting.
(set-logging-fn fn)
Change println
to a custom logging function that Omniconf will use.
Change `println` to a custom logging function that Omniconf will use.
(stop-ssm-poller)
Stop the process that polls SSM for configuration, created by
populate-from-ssm-continually
.
com.grammarly/omniconf.ssm dependency must be on classpath.
Stop the process that polls SSM for configuration, created by `populate-from-ssm-continually`. com.grammarly/omniconf.ssm dependency must be on classpath.
(verify & {:keys [silent]})
Checks if all the required options are provided, if all values are in range,
and prints the configuration. If :quit-on-error
is set, script will exit if
configuration is incorrect. If :silent
is true, don't print the
configuration state.
Checks if all the required options are provided, if all values are in range, and prints the configuration. If `:quit-on-error` is set, script will exit if configuration is incorrect. If `:silent` is true, don't print the configuration state.
(verify-directory-non-empty key dir)
Check if dir
contains at least one file. Also checks that dir
exists.
Check if `dir` contains at least one file. Also checks that `dir` exists.
(verify-file-exists key file)
Check if file or directory denoted by file
exists, raise error otherwise.
Check if file or directory denoted by `file` exists, raise error otherwise.
(with-options bindings & body)
Binds given symbols to respective configuration parameters and executes
body
in that context. Works only for top-level parameters.
Binds given symbols to respective configuration parameters and executes `body` in that context. Works only for top-level parameters.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close