Argx.Defconfig (Argx v1.0.4)
Reuse arg config rule by name.
- config name, arg name and type are necessary.
defconfig(Rule, id(:integer))
Rule
is config name.:Rule
,Rule
or"Rule"
are acceptable.id
is arg name.:string
is type.
:optional
declare arg's value that can be nil.defconfig(Rule, id(:integer, :optional))
:auto
declare that argx convert it to integer value automatically if it is compatible."1"
to1
"1.2"
to1.2
1
to1.0
1
totrue
0
tofalse
"1"
totrue
"0"
tofalse
defconfig(Rule, id(:integer, :auto))
:empty
empty value the same as nil, the following values are empty.0
0.0
""
%{}
[]
defconfig(Rule, id(:integer, :empty))
- range: there are 2 ways to set value's range.
10..20
, between 10 and 20, also include begin value and end value.20
, equal to 20.defconfig(Rule, id(:integer, 10..20))
:list
,:map
and:string
value calculate it's length or size.:integer
and:float
value compare it's value directly.:boolean
value will be ignored.
- default: there are 3 ways to set value's default value.
- a value, such as:
1
. - local function.
- remote function, module name should be fully-qualified name, such as:
YourProject.Helper
.defconfig(Rule, id(:integer) || 0) defconfig(Rule, id(:integer) || get_default_id()) defconfig(Rule, id(:integer) || YourProject.Helper.get_default_id())
- a value, such as:
- multi configs: define them in one rule.
defconfig(Rule, [id(:integer), name(:string)])