glint

Types

pub type CmdResult(a) =
  Result(Out(a))
pub opaque type Command(a)
pub type CommandInput {
  CommandInput(args: List(String), flags: FlagMap)
}

Constructors

  • CommandInput(args: List(String), flags: FlagMap)
pub type Contents(a) {
  Contents(do: Runner(a), flags: FlagMap, desc: Description)
}

Constructors

  • Contents(do: Runner(a), flags: FlagMap, desc: Description)
pub type Description {
  Description(description: String, usage: String)
}

Constructors

  • Description(description: String, usage: String)
pub type Out(a) {
  Out(a)
  Help(String)
}

Constructors

  • Out(a)
  • Help(String)
pub type Runner(a) =
  fn(CommandInput) -> a

Functions

pub fn add_command(to root: Command(a), at path: List(String), do f: fn(
    CommandInput,
  ) -> a, with flags: List(#(String, Contents)), described description: String, used usage: String) -> Command(
  a,
)
pub fn execute(cmd: Command(a), args: List(String)) -> Result(
  Out(a),
  Snag,
)
pub fn new() -> Command(a)
pub fn run(cmd: Command(a), args: List(String)) -> Nil