glint/flag
Types
pub type Contents {
Contents(value: Value, description: Description)
}
Constructors
-
Contents(value: Value, description: Description)
pub type Description =
String
Constants
pub const help_flag_message: String = "--help\t\t\tPrint help information"
pub const help_flag_name: String = "help"
Supported flag types.
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.
Int flags, to be passed in as --flag=1
List(Int) flags, to be passed in as --flag=1,2,3
Float flags, to be passed in as --flag=1.0
List(Float) flags, to be passed in as --flag=1.0,2.0
String flags, to be passed in as --flag=hello
List(String) flags, to be passed in as --flag=hello,world
Flag data and descriptions
Associates a name with a flag value
Creates a Flag(name, I(value))
Creates a Flag(name, LI(value))
Creates a Flag(name, F(value))
Creates a Flag(name, LF(value))
Creates a Flag(name, S(value))
Creates a Flag(name, LS(value))
Creates a Flag(name, B(value))
Associate flag names to their current values.
Convert a list of flags to a Map. Updates a flag balue, 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
Access the contents for the associated flag
Gets the current Value for the associated flag
Computes the new flag value given the input and the expected flag type
Functions
pub fn bool(called name: String, default value: Bool, explained description: String) -> #(
String,
Contents,
)
pub fn flags_help(flags: Map(String, Contents)) -> String
Generate help messages for all flags
pub fn float(called name: String, default value: Float, explained description: String) -> #(
String,
Contents,
)
pub fn floats(called name: String, default value: List(Float), explained description: String) -> #(
String,
Contents,
)
pub fn get_value(from flags: Map(String, Contents), for name: String) -> Result(
Value,
Nil,
)
pub fn int(called name: String, default value: Int, explained description: String) -> #(
String,
Contents,
)
pub fn ints(called name: String, default value: List(Int), explained description: String) -> #(
String,
Contents,
)
pub fn string(called name: String, default value: String, explained description: String) -> #(
String,
Contents,
)
pub fn strings(called name: String, default value: List(String), explained description: String) -> #(
String,
Contents,
)
pub fn update_flags(in flags: Map(String, Contents), with flag_input: String) -> Result(
Map(String, Contents),
Snag,
)