gsh/command/router
The router module intercepts user input to check for built-in shell commands.
Before sending input to the dynamic evaluator (which would try to compile
and execute it as Gleam code), the REPL passes the input here. If it matches
a known command (like h() for help or clear to wipe the screen), the router
executes it immediately and tells the shell loop to skip evaluation.
Types
Represents the routing signal returned to the main shell loop.
pub type CommandResult {
Handled
Exit
Clear
Compile
NotCommand
}
Constructors
-
HandledThe command was recognized, executed, and the shell should prompt again.
-
ExitThe user requested to terminate the shell session (e.g.,
k()). -
ClearThe user requested to clear the terminal screen.
-
CompileThe user requested to recompile the surrounding Mix/Gleam project.
-
NotCommandThe input did not match any built-in commands and should be sent to the standard Gleam evaluator.
Values
pub fn handle(
input: String,
bindings: List(binding.Binding),
history_entries: List(String),
) -> CommandResult
Inspects the raw string input to route it to the appropriate built-in command.
It requires access to the current bindings and history_entries state
so that commands like l() (list bindings) and history() have the
necessary context to print accurate summaries.