feat(cli): add prefix-based command matching and autocomplete module#644
Open
shreejaykurhade wants to merge 1 commit intoQuantConnect:masterfrom
Open
feat(cli): add prefix-based command matching and autocomplete module#644shreejaykurhade wants to merge 1 commit intoQuantConnect:masterfrom
shreejaykurhade wants to merge 1 commit intoQuantConnect:masterfrom
Conversation
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.
GitHub Pull Request: Advanced Autocomplete & Shorthand Command Execution
Summary
This Pull Request introduces significant usability improvements to the Lean CLI. It implements Prefix-based Command Matching (allowing shorthand like
lean clinstead oflean cloud) and a Native Autocomplete Management Module that supports interactive, visual predictions in PowerShell and traditional completion in Bash/Zsh/Fish.Files Changed & Practical Reason
1.
lean/main.pyReason: To resolve "Silent Crashes" during automated tasks (like autocomplete script generation).
Excerpt:
Logic: Prevents Click's clean exit signals from being swallowed by the general exception handler and logged as errors.
2.
lean/components/util/click_aliased_command_group.pyReason: To enable the "Shorthand" feature where typing
lean clresolves and runslean cloud.Excerpt:
Logic: Overrides the standard command lookup. If no exact match is found, it performs a prefix search on all available subcommands.
3.
lean/commands/__init__.pyReason: Registering the new
autocompletecommand group to the main CLI.Excerpt:
4.
lean/commands/<group>/__init__.py(Multiple)Reason: Activating prefix-matching on individual command groups (Cloud, Config, Data, etc.).
Excerpt:
5.
lean/commands/autocomplete.py(Full Module)Reason: A comprehensive management tool for shell-native autocomplete integration.
Key Features:
PSReadLine.enableanddisablecommands to modify$PROFILEor.bashrc.[FULL CODE Logic Snippet]
Verification
lean clsuccessfully executeslean cloud.lean clo+Tabperforms ghost-text prediction.enablecommand successfully injects code into PowerShell profile.Exitcodes are handled cleanly without logging errors.Autocomplete Visual Behavior
🔹 Top-Level Command List
Typing
leanfollowed by a Tab will now trigger a full scan of the command tree and present a visual menu of every available root-level command (e.g.,backtest,cloud,config,data).🔹 Prefix Matching & Expansion
Typing a partial command such as
lean cland pressing Tab will:cl.cloud).🔹 Deep-Level Discovery
The behavior is recursive. Typing
lean cloud+ Tab will correctly discover and list only the sub-commands relevant to the cloud group (pull,push,backtest, etc.).