glint/flag

Types

Associates a name with a flag value

pub type Flag {
  Flag(name: String, value: FlagValue)
}

Constructors

  • Flag(name: String, value: FlagValue)

Associate flag names to their current values.

pub type FlagMap =
  Map(String, FlagValue)

Supported flag types.

pub type FlagValue {
  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

  • 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

Functions

pub fn bool(called name: String, default value: Bool) -> Flag

Creates a Flag(name, B(value))

pub fn build_map(flags: List(Flag)) -> Map(String, FlagValue)

Convert a list of flags to a FlagMap.

pub fn float(called name: String, default value: Float) -> Flag

Creates a Flag(name, F(value))

pub fn float_list(called name: String, default value: List(Float)) -> Flag

Creates a Flag(name, LF(value))

pub fn int(called name: String, default value: Int) -> Flag

Creates a Flag(name, I(value))

pub fn int_list(called name: String, default value: List(Int)) -> Flag

Creates a Flag(name, LI(value))

pub fn string(called name: String, default value: String) -> Flag

Creates a Flag(name, S(value))

pub fn string_list(called name: String, default value: List(
    String,
  )) -> Flag

Creates a Flag(name, LS(value))

pub fn update_flags(flags: Map(String, FlagValue), flag_input: String) -> Result(
  Map(String, FlagValue),
  Snag,
)

Updates a flag balue, ensuring that the new value can satisfy the required type.