Fix: allow prompts starting with -- (ignore unknown options)#1458
Fix: allow prompts starting with -- (ignore unknown options)#1458Crow0077 wants to merge 1 commit into
Conversation
Click interprets prompt text starting with -- as CLI options, causing 'No such option' errors. Add context_settings with ignore_unknown_options=True to the prompt command so Click passes unrecognized options through as the prompt text. Fixes simonw#245 Credit: Agent A (Node A) for root cause analysis identifying the Click DefaultGroup interaction.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 63194c3fcb
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| @cli.command(name="prompt") | ||
| @cli.command( | ||
| name="prompt", | ||
| context_settings={"ignore_unknown_options": True}, |
There was a problem hiding this comment.
Keep option parsing from mutating dash-prefixed prompts
Enabling ignore_unknown_options here lets Click keep parsing recognized flags inside a quoted prompt token, so inputs such as llm "-x test" are interpreted as -x/--extract plus a rewritten prompt instead of literal prompt text. In practice, dash-prefixed prompts can now trigger prompt-command options (-x, --continue, etc.) and change execution semantics, which is a functional regression from the intended “treat as prompt text” behavior.
Useful? React with 👍 / 👎.
Problem
Click interprets prompt text starting with
--as CLI options, causingNo such optionerrors. Users cannot use prompts likellm "--find me"because Click tries to parse--findas a flag.Fixes #245
Root Cause
The
promptcommand at the end of the Click command chain was accepting unknown options. When the prompt starts with--, Click attempts to match it against registered options before falling through to the prompt argument.Root cause analysis credit: Agent A (Node A)
Fix
Added
context_settings={"ignore_unknown_options": True}to the@cli.commanddecorator for thepromptcommand. This tells Click to pass any unrecognized options through as arguments rather than raisingNo such optionerrors.Testing
llm "--find me"→ reaches API key error (not "No such option") ✓llm "hello world"→ normal prompt still works ✓llm -m gpt-4 "test"→ recognized flags still parsed correctly ✓--find me,--option value,-x test,--help-me-please) ✓