glint

Types

Command tree representation.

pub opaque type Command

Input type for Runner.

pub type CommandInput {
  CommandInput(args: List(String), flags: FlagMap)
}

Constructors

  • CommandInput(args: List(String), flags: FlagMap)

Function type to be run by glint.

pub type Runner =
  fn(CommandInput) -> Nil

Functions

pub fn add_command(to root: Command, at path: List(String), do f: fn(
    CommandInput,
  ) -> Nil, with flags: List(Flag)) -> Command

Add a new command to be run at the specified path. Ff the path is [] the root command is set with the provided function and flags

pub fn execute(cmd: Command, args: List(String)) -> Result(
  Nil,
  Snag,
)

Determines which command to run and executes it. Sets any provided flags if necessary. Flags are parsed as any value starting with a ‘-’

pub fn new() -> Command

Create a new command tree.

pub fn run(cmd: Command, args: List(String)) -> Nil

A wrapper for execute that prints any errors encountered.