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
pub type Stub(a) {
  Stub(
    path: List(String),
    run: Runner(a),
    flags: List(Flag),
    description: String,
    usage: String,
  )
}

Constructors

  • Stub(
      path: List(String),
      run: Runner(a),
      flags: List(Flag),
      description: String,
      usage: String,
    )

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 add_command_from_stub(to root: Command(a), with stub: Stub(
    a,
  )) -> Command(a)
pub fn execute(cmd: Command(a), args: List(String)) -> Result(
  Out(a),
  Snag,
)
pub fn help_flag() -> String
pub fn new() -> Command(a)
pub fn run(cmd: Command(a), args: List(String)) -> Nil