Skip to content

fix: allow dash-prefixed positional args without misinterpreting as options#1161

Open
kagura-agent wants to merge 1 commit intojackwener:mainfrom
kagura-agent:fix/dash-positional-args
Open

fix: allow dash-prefixed positional args without misinterpreting as options#1161
kagura-agent wants to merge 1 commit intojackwener:mainfrom
kagura-agent:fix/dash-positional-args

Conversation

@kagura-agent
Copy link
Copy Markdown
Contributor

Problem

When a positional argument value starts with a dash (e.g. opencli boss detail -123456abdc), Commander.js misinterprets it as an unknown option flag and throws error: unknown option '-123456abdc'.

This affects any command where positional argument values can legitimately start with - (like BOSS直聘 security IDs).

Fixes #1160

Solution

Override parseOptions on commands that have positional arguments. Before Commander's option parsing runs, we scan for unrecognized dash-prefixed tokens and insert a -- sentinel so Commander treats them as operands rather than options.

This is a framework-level fix — all 351 commands with positional args benefit automatically.

Changes

  • src/commanderAdapter.ts: Add parseOptions override for commands with positional args
  • src/commanderAdapter.test.ts: Add 3 test cases (dash-prefixed ID, dash ID with options, normal ID)

Testing

  • All 3 new tests pass
  • Full test suite: 1921 passed (9 pre-existing failures in article-extract.test.ts unrelated to this change)
  • npx tsc --noEmit clean

…ptions (jackwener#1160)

When a positional argument value starts with a dash (e.g. `opencli boss detail -123456abdc`),
Commander.js misinterprets it as an unknown option flag and errors out.

Fix: override parseOptions on commands with positional args to insert a `--` sentinel before
the first unrecognized dash-prefixed token, so Commander treats it as an operand.

Fixes jackwener#1160
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: BOSS直聘 detail 命令无法处理以"-"开头的 security-id 参数

1 participant