Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

SpectraCli

Spectra’s command grammar, built applicatively with Std Cli.

The executable understands three subcommands, each defaulting its project path to the current directory:

spectra check [PATH]
spectra build [PATH] --output deck.pdf --open
spectra clean [PATH]

Parsing is a pure function over an argument list, so the grammar is its own test surface:

fn main() =
  match parse_spectra_argv(["build", "talk", "--open"]) of
    C.Parsed(cmd) => println(show(cmd))
    _ => println("usage error")
SpectraCli.Build("talk", "deck.pdf", true)

Types

SpectraCommand

type SpectraCommand
  = Check(String)
  | Build(String, String, Bool)
  | Clean(String)
  deriving (Eq, Show)

One parsed subcommand: check a project, build it to a named PDF and optionally open it, or clean its build directory.

Functions and Values

spectra_command

spectra_command : Cli.Command(SpectraCommand)

The whole command grammar the executable parses its argument list with.

parse_spectra_argv

parse_spectra_argv : (List(String)) -> Cli.Outcome(SpectraCommand)

Parse an argument list against the grammar, without touching the process environment.