gsh

gsh is the core entry point for the Interactive Gleam Shell.

It acts as a development orchestrator, providing two main capabilities:

  1. Zero-Config Bootloader: Intercepts CLI arguments to dynamically boot host applications in the background (e.g., gleam run -m gsh -- my_app).
  2. Persistent REPL: A live-node interactive shell that maintains VM state, memoizes side effects, and safely handles runtime exceptions while toggling terminal raw mode to ensure clean I/O.

Types

Holds the persistent state of the shell session across evaluations. This state is passed recursively through the REPL loop to maintain history, variable bindings, and declared types/functions.

pub type ShellState {
  ShellState(
    prompt_count: Int,
    bindings: List(binding.Binding),
    imports: List(String),
    types: List(String),
    history: List(String),
    functions: List(String),
  )
}

Constructors

  • ShellState(
      prompt_count: Int,
      bindings: List(binding.Binding),
      imports: List(String),
      types: List(String),
      history: List(String),
      functions: List(String),
    )

Values

pub fn main() -> Nil

The main entry point.

  1. Intercepts trailing CLI arguments to boot background applications and print their PIDs.
  2. Places the terminal into raw mode for character-by-character input processing.
  3. Starts the recursive REPL loop.
Search Document