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. check and build shell out to the compiler named by --prism, so a fresh build can pin itself instead of trusting whichever prism is first on PATH:

spectra check [PATH] --prism prism
spectra build [PATH] --output deck.pdf --open --prism prism
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, "prism")

Types

SpectraCommand

type SpectraCommand
  = Check(String, String)
  | Build(String, String, Bool, String)
  | 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. The last field of Check and Build is the compiler binary their shell steps invoke.

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.