glint/flag
Types
Flag data and descriptions
pub type Contents {
Contents(value: Value, description: Description)
}
Constructors
-
Contents(value: Value, description: Description)
Flag descriptions
pub type Description =
String
Supported flag types.
pub type Value {
B(Bool)
I(Int)
LI(List(Int))
F(Float)
LF(List(Float))
S(String)
LS(List(String))
}
Constructors
-
B(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(Int)
Int flags, to be passed in as
--flag=1
-
LI(List(Int))
List(Int) flags, to be passed in as
--flag=1,2,3
-
F(Float)
Float flags, to be passed in as
--flag=1.0
-
LF(List(Float))
List(Float) flags, to be passed in as
--flag=1.0,2.0
-
S(String)
String flags, to be passed in as
--flag=hello
-
LS(List(String))
List(String) flags, to be passed in as
--flag=hello,world
Constants
Functions
pub fn bool(called name: String, default value: Bool, explained description: String) -> #(
String,
Contents,
)
Creates a #(name, Contents(B(value), description))
pub fn build_map(flags: List(#(String, Contents))) -> Map(
String,
Contents,
)
Convert a list of flags to a Map.
pub fn flag_type_help(flag: #(String, Contents)) -> String
Generate the help message contents for a single flag
pub fn flags_help(flags: Map(String, Contents)) -> List(String)
Generate help messages for all flags
pub fn float(called name: String, default value: Float, explained description: String) -> #(
String,
Contents,
)
Creates a #(name, Contents(F(value), description))
pub fn floats(called name: String, default value: List(Float), explained description: String) -> #(
String,
Contents,
)
Creates a #(name, Contents(LF(value), description))
pub fn get(from flags: Map(String, Contents), for name: String) -> Result(
Value,
Nil,
)
Gets the current Value for the associated flag
pub fn int(called name: String, default value: Int, explained description: String) -> #(
String,
Contents,
)
Creates a #(name, Contents(I(value), description))
pub fn ints(called name: String, default value: List(Int), explained description: String) -> #(
String,
Contents,
)
Creates a #(name, Contents(LI(value), description))
pub fn string(called name: String, default value: String, explained description: String) -> #(
String,
Contents,
)
Creates a #(name, Contents(S(value), description))
pub fn strings(called name: String, default value: List(String), explained description: String) -> #(
String,
Contents,
)
Creates a #(name, Contents(LS(value), description))
pub fn update_flags(in flags: Map(String, Contents), with flag_input: String) -> Result(
Map(String, Contents),
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