module

Shell::AutoComplete::Completion::Positional

Maps a completion cursor onto a positional-argument slot.

Class methods

flag_token?(tok : String) : Bool

A token that looks like a flag: starts with - but isn't a bare -.

Source
index_at(words : Array(String), cword : Int32, value_flag_names : Set(String), bare_number_patterns : Array(Regex) = [] of Regex) : Int32 | Nil

Returns the 0-based positional slot the cursor sits on, accounting for flags and the values they consume, or nil when the cursor is not on a positional (it's a flag name, or the value of a value-taking flag).

value_flag_names is the set of flag tokens (canonical, aliases, short forms) for flags that take a value; bool flags are excluded because they consume no following token. Mirrors the parser's argument consumption: --flag=value is a single token, a -- terminator forces everything after it to be positional.

bare_number_patterns holds the shapes of any bare_number: flags. A -20 token already reads as a flag, but a +50 does not, and counting it as a positional would shift every slot after it by one.

Source