Skip to content

Fix llm -- prompt not treating argument as positional - #1665

Open
ikatyal2110 wants to merge 1 commit into
simonw:mainfrom
ikatyal2110:fix/double-dash-default-command
Open

ikatyal2110 wants to merge 1 commit into
simonw:mainfrom
ikatyal2110:fix/double-dash-default-command

Conversation

@ikatyal2110

Copy link
Copy Markdown
Contributor

When running llm -- "--find me", the cli group (DefaultGroup) consumes the -- separator and forwards "--find me" to the prompt subcommand without the separator, so Click's parser mistakes it for an option and raises "No such option: --find me". The equivalent llm prompt -- "--find me" works correctly because the separator reaches the prompt command intact.

The fix detects when -- is the first argument to the cli group and injects the default command name (prompt) before it, so ['--', arg] becomes ['prompt', '--', arg] and the separator is forwarded to the subcommand as intended. A regression test using the echo model verifies the prompt value is received correctly.

Fixes #245


Generated by Claude Code

When the user runs `llm -- "--option-like-prompt"`, the cli group
(DefaultGroup) consumes the `--` separator and passes the option-like
string directly to the prompt subcommand without the separator.
The subcommand's parser then mistakes it for an option and raises
"No such option".

Detect the case where `--` is the first argument and inject the
default command name before it so the separator is forwarded intact to
the subcommand, mirroring the behaviour of `llm prompt -- "..."`.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015J3gVny9MN8kFEQaQvMqSk
@simonw

simonw commented Sep 19, 2026

Copy link
Copy Markdown
Owner

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

2 participants