zensols.actioncli.resource

A file system/resource configuration package.

*resource-paths*

dynamic

Meant for this namespace internal use only.

register-resource

(register-resource key & {:keys [function pre-path constant type system-file system-property system-default], :or {type :file}})

Register a resource to be used with resource-path. This should be done at the beginning of the program, usually from core. key: the key to be used for the resource with resource-path.

Keys

All keys are optional but at least :function or :system-file must be provided.

  • :function the function to call when the resource is generated (see the resource test and example of how to use this)
  • :type the type of resource to return; one of :resource or :file (default)
  • :pre-path a key of a resource to prepend to the path
  • :system-file a file path of the resource–if the same name exists as a system property then that is used instead (see set-resource-property-format)
  • :system-default the default path to use if the system-file isn’t found in the system properties
  • :system-property get the resource directly from the system properties

resource-path

(resource-path key child-file & {:keys [create], :or {create nil}})(resource-path key)

Get a path to a resource. Before using this you must register resources with register-resource.

Keys

  • :create if :file then create the director(ies) on the file system, otherwise if :dir then create all parent directories

set-resource-property-format

(set-resource-property-format fmt-str)

The format string (used with format) to generate the system property for resource string lookups in the system properties.

with-resources

macro

(with-resources & forms)

Allows for temporal registration and path rendering in a lexical context.