tab complete root flags if - or -- provided, otherwise complete comma…#379
Merged
Conversation
…nds or command flags
Contributor
Reviewer's GuideUpdates the zsh completion script for the Sequence diagram for updated zsh completion root flag handlingsequenceDiagram
participant User
participant zsh as zsh_completion
participant _lets
participant _lets_root_flags_before_command
participant _check_lets_config
participant lets as LETS_EXECUTABLE
User->>zsh: Press TAB after lets -c custom.yaml cmd
zsh->>_lets: _lets
_lets->>_lets_root_flags_before_command: _lets_root_flags_before_command
_lets_root_flags_before_command-->>_lets: reply (root_flags)
_lets->>_check_lets_config: _check_lets_config root_flags
_check_lets_config->>lets: lets root_flags completion --commands --verbose
lets-->>_check_lets_config: exit_code
_check_lets_config-->>_lets: exit_code
alt commands completion
_lets->>lets: lets root_flags completion --commands --verbose
lets-->>_lets: command_list
else options completion
_lets->>lets: lets root_flags completion --options=cmd --verbose
lets-->>_lets: option_list
end
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Contributor
There was a problem hiding this comment.
Hey - I've found 1 issue, and left some high level feedback:
- The flag-handling logic in
_lets_root_flags_before_commandand_lets_active_commandduplicates the same case patterns; consider centralizing the supported root flags in a shared helper or data structure to keep them from drifting out of sync. - The updated
_check_lets_confignow accepts arbitrary arguments and is used in multiple places; it might be clearer to document or enforce that it only expects root flags so accidental non-flag arguments don’t produce surprising behavior.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The flag-handling logic in `_lets_root_flags_before_command` and `_lets_active_command` duplicates the same case patterns; consider centralizing the supported root flags in a shared helper or data structure to keep them from drifting out of sync.
- The updated `_check_lets_config` now accepts arbitrary arguments and is used in multiple places; it might be clearer to document or enforce that it only expects root flags so accidental non-flag arguments don’t produce surprising behavior.
## Individual Comments
### Comment 1
<location path="internal/cmd/completion.go" line_range="58" />
<code_context>
+ _lets_active_command() {
</code_context>
<issue_to_address>
**suggestion:** Consider treating `--` as a hard stop when determining the active command.
In `_lets_active_command`, `--` is currently treated like other flags and skipped:
```sh
case "$token" in
-c|--config|-E|--env|--only|--exclude)
((idx++))
;;
--config=*|--env=*|--only=*|--exclude=*|-E*|-d|-dd|--debug|--all|--init|--)
;;
```
But `_lets_root_flags_before_command` uses `--` as a terminator. To keep behavior consistent and avoid mis-identifying a post-`--` argument as the command, `_lets_active_command` should `break` when it sees `--` instead of skipping it.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
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.
…nds or command flags
Summary by Sourcery
Improve zsh completion behavior for root flags and commands in the lets CLI.
Bug Fixes:
command -c not declared in configduring completion.Documentation: