glint

Types

Command tree representation.

pub opaque type Command(a)

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(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(Flag)) -> Command(a)

Adds a new command to be run at the specified path.

If the path is [], the root command is set with the provided function and flags.

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

Determines which command to run and executes it.

Sets any provided flags if necessary.

Each value prefixed with -- is parsed as a flag.

pub fn new() -> Command(a)

Creates a new command tree.

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

A wrapper for execute that discards output and prints any errors encountered.