Documentation
¶
Overview ¶
Package nushell renders completion results as a bare JSON array of records for nushell's external completer and generates the nushell registration snippet for the wire protocol (docs/completion-wire-protocol.md).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Format ¶
Format renders candidates and directives in the nushell framing: a bare JSON array of records (no trailing newline) in engine order. The record's value is pre-quoted for direct insertion (nushell inserts it verbatim), with the nospace rule expressed as a trailing space baked into the value. Nushell's external-completer contract has no directive, message, or usage channel: noprefix, keeporder, messages, and usage are silently dropped. The framing is position-independent: toComplete is accepted for seam symmetry and ignored.
func Patch ¶
Patch dequotes nushell's raw completion spans: nushell passes completed positions still quoted, while the engine expects resolved tokens. Double- and single-quoted spans are re-lexed to their first quote-resolved word (only when the leading quote is closed — an unterminated span is the word being completed and passes through raw); backtick-wrapped spans lose their backticks; every other word passes through unchanged.
func Snippet ¶
Snippet renders the nushell registration script for the given command name: a global external completer closure (nushell has one completer for all external commands, discriminated by the command name in $spans.0) plus a defensive merge into $env.config.completions.external that preserves an existing completer and the nushell #15654 enable default. The closure validates the span count (guarding against empty spans), wraps the completion invocation in try-catch for robustness, drops the command name (the first span), and feeds the remaining spans to the binary's __complete entry point (docs/completion-wire-protocol.md). Aliases need no separate registration: the global completer resolves the name the user typed from the spans.
Types ¶
This section is empty.