Skip to main content

Module cmd

Module cmd 

Source
Expand description

Command name → action index with front-prefix completion.

Ex-command input (:wq, :w file) decomposes into three stages, none of which require a new library type for execution: : is an ordinary Keymap::get hit, text accumulates in a caller-owned line buffer, and Enter dispatches through a FnMut(&str) -> Option<A> — see examples/ex_command.rs.

What a caller-owned name table cannot give cheaply is the discovery layer: :w<Tab> completions (front-prefix enumeration) and a full command listing for a palette. CommandIndex is that one type — a name-keyed BTreeMap whose complete method is the primary differentiator.

The design deliberately avoids a closed result enum: :w can be both an exact command and the prefix of :wq and :wqa, so get and complete are two orthogonal pure functions rather than a merged discriminant. Normalisation (trim, case-fold) and dispatch are the caller’s responsibility; the index stores names byte-for-byte as bound.

Structs§

CommandIndex
A name-to-action index with front-prefix completion.