Skip to main content

Module command_options_query

Module command_options_query 

Source
Expand description

Final-state and position questions over a tokenized region. What: Small read-only questions over a tokenized Git argument region. Why: Git applies options in order and the last use wins, so command modules ask for final states and positions instead of counting spellings.

In TS you’d write (pseudocode):

// lastOccurrence(parsed, id), isEnabled(parsed, id), positionalTokens(parsed, length), ...

Structs§

WrapperFlags
What: Wrapper-only flags found in option position, split into the command’s own escape hatch and every other flag the caller listed. Why: A rule asks “was my hatch written?”, while the caller removes all of them by position.

Functions§

is_enabled
What: Whether the option is on after every use was applied. Why: --all --no-all leaves all off, exactly as Git’s OPT_BOOL does.
is_stated
What: Whether the option was written at all, in either form. Why: An explicit --no-only is a stated choice even though it turns the option off.
last_occurrence
What: The final use of the option id, or nothing. &ParsedOptions borrows the result read-only; u16 is the identifier type of table rows. Why: Git’s variables keep what the last matching option wrote.
positional_tokens
What: Every non-option token index in order: those before the boundary, then every token after it. length is the region’s token count. Why: Git hands the command both groups as its remaining arguments. Gotcha: Under Boundary::NonOption the boundary token itself is positional; under -- and --end-of-options it is not.
split_wrapper_flags
What: Split the wrapper occurrences of a parse whose flag list was built as “own escape hatch first, then the caller’s flags”. &[WrapperOccurrence] borrows the occurrence list of that parse. Why: Every command module builds its list that way, so the caller’s indexes are the tokenizer’s indexes minus one.
value_bytes
What: The exact bytes of an option value. &[u8] borrows them from arguments. Why: Values are compared as bytes; converting to String would reject non-UTF-8 text.
without_tokens
What: Copy arguments without the tokens at removed, which are indexes relative to offset (the index of the first region token). Why: Wrapper-only flags are deleted by position, so an equal-looking value or path stays.