class
Jargon::Completion
- Jargon::Completion
- Reference
- Object
Overview
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.
Defined in:
jargon/completion.crConstant Summary
-
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
Instance Method Summary
-
#bash(command : String) : String
Bash splits words at
=and:(they are in COMP_WORDBREAKS), so--mode=faarrives as--mode,=,fa. -
#candidates(words : Array(String), cword : Int32) : Array(String)
Compute completion candidates for a tokenized command line.
- #fish(command : String) : String
- #zsh(command : String) : String
Constructor Detail
Instance Method Detail
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.
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).