Struct calypso_repl::Repl
source · pub struct Repl<Ctx> {
pub(crate) eval: Eval<Ctx>,
pub(crate) cmds: Vec<Arc<Command<Ctx>>>,
pub(crate) cache: HashMap<String, Arc<Command<Ctx>>>,
pub(crate) editor: Editor<()>,
pub(crate) ctx: Ctx,
pub(crate) prefix: String,
pub(crate) cmd_regex: Regex,
}
Expand description
A struct for doing REPL-like activities. This does not necessarily need to fit the exact definition of REPL (Read, Eval, Print, Loop).
The Ctx
type parameter can be any type of REPL-global context, e.g. a parser context or perhaps an environment structure.
The command help
, with aliases ['h', '?']
is reserved.
Fields§
§eval: Eval<Ctx>
A closure that evaluates the input and returns something implementing Display
cmds: Vec<Arc<Command<Ctx>>>
Meta-command definitions. This is a Vec
as you may want to dynamically initialize commands.
cache: HashMap<String, Arc<Command<Ctx>>>
A HashMap containing references to the commands. This is cached to allow faster command execution.
editor: Editor<()>
The Rustyline context
ctx: Ctx
The context
prefix: String
Prefix for commands. Default: :
cmd_regex: Regex
Regex for commands