class

Jargon::Completion

Inherits Reference < Object

Shell completion: generates a small "shim" script per shell that, on every Tab, forwards the cursor position and typed words to the program itself (the hidden __complete verb). The program then computes candidates from the schema plus any registered dynamic completers — so static (flags, enums, subcommands) and dynamic (live app data) completion share one path.

Constants

COMPLETE_VERB = "__complete"

Hidden subcommand the generated shim invokes at completion time. Never written by the developer — it is an internal token between the shim and CLI#handle_completion.

Constructors

new(cli : CLI)
Source

Instance methods

bash(command : String) : String

Bash splits words at = and : (they are in COMP_WORDBREAKS), so --mode=fa arrives as --mode, =, fa. The shim rejoins pieces that have no whitespace between them in COMP_LINE, so the program sees the same words zsh and fish report, then trims each candidate back to the part after the last break, which is all readline replaces.

Source
candidates(words : Array(String), cword : Int32) : Array(String)

Compute completion candidates for a tokenized command line. words includes the program name at index 0; cword is the index of the word under the cursor (may equal words.size when completing a fresh token).

Source
fish(command : String) : String
Source
zsh(command : String) : String
Source

Nested types