mix schooner.repl (schooner v1.2.0)

Copy Markdown View Source

Starts an interactive session against your application's real environment, built on Schooner.Session. Something that works here works in production, and something that's unbound in production is unbound here too.

$ mix schooner.repl --env MyApp.Scripts.environment
Schooner 1.1.0 — environment: MyApp.Scripts.environment/0. ,help for commands.
schooner> (define (with-shipping x)
     ...>   (+ x 5))
schooner> (with-shipping 30)
35

Definitions, imports and define-syntax macros persist from one entry to the next. An entry that ends inside an open form continues on the next line, and in a terminal that line starts indented to where the code goes, as Schooner.Pretty would lay it out: a body two columns in, the arguments of a call under the first. Tab re-indents a line, Up and Down recall earlier entries, and Ctrl-C interrupts an evaluation that runs too long, leaving the session as it was before it. Ctrl-D or ,quit leaves.

An error is printed, and the session carries on.

Commands

  • ,env [prefix] — list the bindings in scope, or those whose name starts with prefix: each one's name, the library it comes from, and what it is.
  • ,expand <form> — show what <form> expands to, with the session's macros.
  • ,time <form> — evaluate <form> and report its wall time and reductions.
  • ,load <file> — evaluate a file into the session.
  • ,help, ,quit.

Options

  • --env Mod.fun — evaluate against the Schooner.Environment returned by the zero-arity function Mod.fun. Without it, the environment is the one configured with

    config :schooner, :tooling_environment, {Mod, :fun, args}

    and without that, every standard library, all imported: the surface Schooner.run/1 gives a script that imports nothing.

  • --load FILE — evaluate FILE into the session before the first prompt. Repeat it to load several, in order.

  • --debug — evaluate with debug: true, so errors carry their location and a Scheme backtrace.

When standard input isn't a terminal, the task reads whole lines, without editing or indenting them, so you can pipe a script in. Ctrl-C then reaches the BEAM, as in any other mix task.