Fix llm -- prompt not treating argument as positional - #1665
Open
ikatyal2110 wants to merge 1 commit into
Open
ikatyal2110 wants to merge 1 commit into
ikatyal2110 wants to merge 1 commit into
Conversation
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
Owner
|
See also the upstream bug I filed: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 equivalentllm 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