class Jargon::Completion

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.cr

Constant 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

Constructor Detail

def self.new(cli : CLI) #

Instance Method Detail

def 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.


def 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).


def fish(command : String) : String #

def zsh(command : String) : String #