Skip to content

Fix: allow prompts starting with -- (ignore unknown options)#1458

Open
Crow0077 wants to merge 1 commit into
simonw:mainfrom
Crow0077:fix/issue-245-dash-prompt
Open

Fix: allow prompts starting with -- (ignore unknown options)#1458
Crow0077 wants to merge 1 commit into
simonw:mainfrom
Crow0077:fix/issue-245-dash-prompt

Conversation

@Crow0077
Copy link
Copy Markdown

Problem

Click interprets prompt text starting with -- as CLI options, causing No such option errors. Users cannot use prompts like llm "--find me" because Click tries to parse --find as a flag.

Fixes #245

Root Cause

The prompt command 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.command decorator for the prompt command. This tells Click to pass any unrecognized options through as arguments rather than raising No such option errors.

@cli.command(
    name="prompt",
    context_settings={"ignore_unknown_options": True},
)

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 ✓
  • Added parametrized test with 4 variants (--find me, --option value, -x test, --help-me-please) ✓
  • Full test suite: 613 passed, 0 regressions (56 pre-existing failures in async/OpenAI tests)

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.
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread llm/cli.py
@cli.command(name="prompt")
@cli.command(
name="prompt",
context_settings={"ignore_unknown_options": True},
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

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.

llm -- "--find me" doesn't work but llm prompt -- "--find me" does

1 participant