config v0.1.0 Config.Option

Handles macroses to define config option.

Summary

Types

t :: %Config.Option{default: any, env: [String.t], name: Atom.t, switches: [String.t], type: :string | :integer | :boolean | atom}

Macros

option(name)

Specifies configuration option.

Available only inside Config.config/2 and Config.Category.category/2 blocks.

name argument is required.

type is :string by default. You can specify str or string, int or integer, bool or boolean here as atom or like a var name. Also you can define your own types and specify here module that uses Config.Type.

last argument is options. It can be a list or a keyword.

If options contains any underscored name as atom (:some_opt, :n), as string ("some_opt", "n") or as a var name (some_opt, n) this value treated as command-line switch name (--some-opt and -n for given example). One dash added if name length equal to 1. Moreover direct switch syntax ("--some-opt", "-n") in strings supported.

If options contains a capitalized name (:SOME_VAR, "SOME_VAR" or just SOME VAR) this value treated as environment variable name.

You can specify switches and environment variables with keyword syntax: switch: "--some-opt -n", env: ~w(SOME_VAR).

Default value specified with keyword key default, for example: default: 100.

option(name, option_type_or_opts)
option(name, option_type, opts)