Skip to content

Do not consume json-envelope when it is an option value #4976

Description

@Widthdom

Summary

The global JSON-envelope preprocessor consumes a separated option value when that value is the literal --json-envelope. This corrupts the remaining argument positions before command-specific parsing.

Reproduced with locally built cdidx v1.40.3 from origin/main at 2a1313b87ed361bbabe78eba848b6352cecd3dd0.

Reproduction

$ cdidx search --query --json-envelope --db .cdidx/codeindex.db --json=array
Error: unexpected extra positional 1 argument for search: `.cdidx/codeindex.db`.

The equivalent inline value is not consumed and works:

$ cdidx search --query=--json-envelope --db .cdidx/codeindex.db --count
78

Existing issue relationship

No exact open issue was found.

Expected behavior and scope

Global-option preprocessing must classify token roles before consuming --json-envelope. A token used as the separated value of --query or another value-taking option must remain command data, while an actual global --json-envelope option must keep its current behavior.

Cover separated and inline values, option ordering, the positional -- query form, other value-taking options whose values may equal a global flag, and normal envelope output.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions