glint/flag
Types
Flag descriptions
pub type Description =
String
Flag data and descriptions
pub type Flag {
Flag(value: Value, description: Description)
}
Constructors
-
Flag(value: Value, description: Description)
A type that facilitates the creation of Flag
s
pub opaque type FlagBuilder(a)
Supported flag types.
pub type Value {
B(Internal(Bool))
I(Internal(Int))
LI(Internal(List(Int)))
F(Internal(Float))
LF(Internal(List(Float)))
S(Internal(String))
LS(Internal(List(String)))
}
Constructors
-
B(Internal(Bool))
Boolean flags, to be passed in as
--flag=true
or--flag=false
. Can be toggled by omitting the desired value like--flag
. Toggling will negate the existing value. -
I(Internal(Int))
Int flags, to be passed in as
--flag=1
-
LI(Internal(List(Int)))
List(Int) flags, to be passed in as
--flag=1,2,3
-
F(Internal(Float))
Float flags, to be passed in as
--flag=1.0
-
LF(Internal(List(Float)))
List(Float) flags, to be passed in as
--flag=1.0,2.0
-
S(Internal(String))
String flags, to be passed in as
--flag=hello
-
LS(Internal(List(String)))
List(String) flags, to be passed in as
--flag=hello,world
Constants
Functions
pub fn build(fb: FlagBuilder(a)) -> Flag
convert a FlagBuilder(a) into its corresponding Flag representation
pub fn build_map(
flags: List(#(String, Flag)),
) -> Dict(String, Flag)
Convert a list of flags to a Map.
pub fn constraint(
builder: FlagBuilder(a),
constraint: fn(a) -> Result(Nil, Snag),
) -> FlagBuilder(a)
attach a constraint to a Flag
pub fn default(
for builder: FlagBuilder(a),
of default: a,
) -> FlagBuilder(a)
Set the default value for a flag Value
pub fn description(
for builder: FlagBuilder(a),
of description: String,
) -> FlagBuilder(a)
attach a description to a Flag
pub fn get_bool(
from flags: Dict(String, Flag),
for name: String,
) -> Result(Bool, Snag)
Gets the current value for the associated bool flag
pub fn get_bool_value(from flag: Flag) -> Result(Bool, Snag)
Gets the current value for the provided bool flag
pub fn get_float(
from flags: Dict(String, Flag),
for name: String,
) -> Result(Float, Snag)
Gets the current value for the associated float flag
pub fn get_float_value(from flag: Flag) -> Result(Float, Snag)
Gets the current value for the provided float flag
pub fn get_floats(
from flags: Dict(String, Flag),
for name: String,
) -> Result(List(Float), Snag)
Gets the current value for the associated floats flag
pub fn get_floats_value(
from flag: Flag,
) -> Result(List(Float), Snag)
Gets the current value for the provided floats flag
pub fn get_int(
from flags: Dict(String, Flag),
for name: String,
) -> Result(Int, Snag)
Gets the current value for the associated int flag
pub fn get_int_value(from flag: Flag) -> Result(Int, Snag)
Gets the current value for the provided int flag
pub fn get_ints(
from flags: Dict(String, Flag),
for name: String,
) -> Result(List(Int), Snag)
Gets the current value for the associated ints flag
pub fn get_ints_value(from flag: Flag) -> Result(List(Int), Snag)
Gets the current value for the provided ints flag
pub fn get_string(
from flags: Dict(String, Flag),
for name: String,
) -> Result(String, Snag)
Gets the current value for the associated string flag
pub fn get_string_value(from flag: Flag) -> Result(String, Snag)
Gets the current value for the provided string flag
pub fn get_strings(
from flags: Dict(String, Flag),
for name: String,
) -> Result(List(String), Snag)
Gets the current value for the associated strings flag
pub fn get_strings_value(
from flag: Flag,
) -> Result(List(String), Snag)
Gets the current value for the provided strings flag
pub fn string_list() -> FlagBuilder(List(String))
intitialise a string list flag builder
pub fn update_flags(
in flags: Dict(String, Flag),
with flag_input: String,
) -> Result(Dict(String, Flag), Snag)
Updates a flag value, ensuring that the new value can satisfy the required type. Assumes that all flag inputs passed in start with – This function is only intended to be used from glint.execute_root