The envy Reference Manual

This is the envy Reference Manual, version 0.1, generated automatically by Declt version 4.0 beta 2 "William Riker" on Mon Feb 26 16:21:35 2024 GMT+0.

Table of Contents


1 Introduction


2 Systems

The main system appears first, followed by any subsystem dependency.


2.1 envy

Configuration switcher by an environment variable.

Author

Eitarow Fukamachi

License

BSD 2-Clause

Long Description

# Envy

Configuration switcher by an environment variable inspired by Perl’s [Config::ENV](http://search.cpan.org/~satoh/Config-ENV/lib/Config/ENV.pm).

## Usage

“‘common-lisp
(defpackage :myapp.config
(:use :cl
:envy))
(in-package :myapp.config)

(setf (config-env-var) "APP_ENV")

(defconfig :common
‘(:application-root ,(asdf:component-pathname (asdf:find-system :myapp))))

(defconfig |development|
’(:debug T
:database-type :sqlite3
:database-connection-spec (:database-name "sqlite3.db")))

(defconfig |production|
’(:database-type :mysql
:database-connection-spec (:database-name "test"
:usename "whoami"
:password "1234")))

(defconfig |staging|
‘(:debug T
,@|production|))
“‘

“‘common-lisp
(defpackage :myapp
(:use :cl)
(:import-from :envy
:config)
(in-package :myapp)

(getf (config :myapp.config) :database-type)
“‘

### Calling APP_ENV from the command line

For example, ‘APP_ENV=development sbcl‘ runs a REPL process that uses development config values.

## Description

Envy is a configuration manager for various applications.

Envy uses an environment variable to determine a configuration to use. I’m not sure this is ideal even for Common Lisp applications, but this can separate configuration system from an implementation.

## Configurations

### Normal configurations

‘ENVY:DEFCONFIG‘ is a macro for defining a named configuration.

Don’t forget to set ‘(ENVY:CONFIG-ENV-VAR)‘ which is a name of environment variable to determine a configuration.

“‘common-lisp
(setf (config-env-var) "APP_ENV")

;; Use SQLite3 for development
(defconfig |development|
’(:server :hunchentoot
:database-type :sqlite3
:database-connection-spec (:database-name "sqlite3.db")))

;; Use MySQL in production environment
(defconfig |production|
’(:server :fcgi
:database-type :mysql
:database-connection-spec (:database-name "test"
:usename "whoami"
:password "1234")))
“‘

### Merging

Each configurations are represented as property lists. It means you can merge them by the default way of merging lists – cons, append or/and splicing unquote.

“‘common-lisp
(defconfig |staging|
‘(:server :hunchentoot
,@|production|))
“‘

### Common configurations

You can also define a common configuration which will be used by all configurations.

“‘common-lisp
(defconfig :common
‘(:application-root ,(asdf:component-pathname (asdf:find-system :myapp))))
“‘

### Accessing to configuration

‘ENVY:CONFIG‘ is an accessor to get the current configuration.

“‘common-lisp
(config :<configuration-package-name>)

(config :myapp.config)
;=> ’(:server :hunchentoot
:database-type :sqlite3
:database-connection-spec (:database-name "sqlite3.db")
:application-root #P"/path/to/application/")

(getf (config :myapp.config) :database-type)
;=> :sqlite3
“‘

## Tips

“‘common-lisp
(defpackage myapp.config
(:use :cl
:envy)
(:shadow :envy
:config)
(:export :config))
(in-package :myapp.config)

(defconfig :common
...)

;;
;; ... Configurations ...
;;

(defun config ()
(envy:config #.(package-name *package*)))
“‘

## See Also

Thank cho45 for the great product. I feel envy to you :)

- [Config::ENV](http://search.cpan.org/~satoh/Config-ENV/lib/Config/ENV.pm)

## Author

* Eitarow Fukamachi (e.arrows@gmail.com)

## Copyright

Copyright (c) 2013 Eitarow Fukamachi (e.arrows@gmail.com)

# License

Licensed under the BSD 2-Clause License.

Version

0.1

Source

envy.asd.

Child Component

src (module).


3 Modules

Modules are listed depth-first from the system components tree.


3.1 envy/src

Source

envy.asd.

Parent Component

envy (system).

Child Component

envy.lisp (file).


4 Files

Files are sorted by type and then listed depth-first from the systems components trees.


4.1 Lisp


4.1.1 envy/envy.asd

Source

envy.asd.

Parent Component

envy (system).

ASDF Systems

envy.

Packages

envy-asd.


4.1.2 envy/src/envy.lisp

Source

envy.asd.

Parent Component

src (module).

Packages

envy.

Public Interface
Internals

5 Packages

Packages are listed by definition order.


5.1 envy

Source

envy.lisp.

Use List

common-lisp.

Public Interface
Internals

5.2 envy-asd

Source

envy.asd.

Use List
  • asdf/interface.
  • common-lisp.

6 Definitions

Definitions are sorted by export status, category, package, and then by lexicographic order.


6.1 Public Interface


6.1.1 Macros

Macro: defconfig (name configurations)
Package

envy.

Source

envy.lisp.


6.1.2 Ordinary functions

Function: config (package-name &optional key)
Package

envy.

Source

envy.lisp.

Function: config-env-var (&optional package-name)
Package

envy.

Source

envy.lisp.

Function: (setf config-env-var) (&optional package-name)
Package

envy.

Source

envy.lisp.


6.2 Internals


6.2.1 Special variables

Special Variable: *config-env-map*
Package

envy.

Source

envy.lisp.

Special Variable: *package-common-configurations*
Package

envy.

Source

envy.lisp.


6.2.2 Ordinary functions

Function: config* (&optional key)
Package

envy.

Source

envy.lisp.

Function: package-config (package-name)
Package

envy.

Source

envy.lisp.


Appendix A Indexes


A.1 Concepts