Powershell auto completion - #645
Open
nehemiaharchives wants to merge 8 commits into
Open
Conversation
- Filter option names, fixed candidates, and fallback completions with Where-Object for proper partial-input narrowing - Add PowerShell docs to CompletionCandidates.kt KDoc and autocomplete.md - Accept "powershell" only in CompletionGenerator.kt (not "pwsh")
…ings, correct context routing
Three bugs fixed:
1. Multiple Register-ArgumentCompleter -Native blocks consolidated into a
single block with switch -Wildcard dispatch based on joined command-path.
PowerShell only keeps the LAST registered block per command name, so the
old per-subcommand-block approach meant deeper blocks overrode shallower
ones and all non-root guards were dead code.
2. Context guard conditions fixed: old code used \[0] -ne 'bbl'
but the loop starts at i=1 (skipping CommandElements[0]=command name), so
\[0] is the first subcommand, never 'bbl'. Replaced with
switch -Wildcard on \ = \ -join ' ' with exact-then-
wildcard ordering (deepest first).
3. [CompletionResult]::new() replaced with plain strings for -Native switch
compatibility in PowerShell 7.6.2. The -Native flag requires ScriptBlock
to return strings (auto-converted to CompletionResult objects).
Also adds wildcard cases ('config *') for partial/unknown subcommand typing
so that e.g. 'bbl c<TAB>' still suggests root-level completions filtered
by 'c*'.
Comment on lines
+1
to
+7
| jdk: | ||
| - openjdk17 | ||
| before_install: | ||
| - sdk install java 17.0.1-open | ||
| - sdk use java 17.0.1-open | ||
| install: | ||
| - ./gradlew publishToMavenLocal --exclude-task test -PRELEASE_SIGNING_ENABLED=false |
There was a problem hiding this comment.
Hi! I don't think this is related to this PR. You might want to remove it so the maintainer can focus on the completion feature.
Author
There was a problem hiding this comment.
Removed in 8263465 forgot to do that before submitting PR. Thank you for finding it out!
|
Thanks a lot for this! I'm really looking forward to it! ❤️ |
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.
Hi, I'm author of bbl - a command line tool to read and search Bible.
bbl is build based on clikt and it provides autocompletion feature for bash, zsh, and fish for macOS and linux.
bbl is kotlin/native program which targets macosArm64, macosX64, linuxX64 and mingwX64.
Only the missing part for mingwX64 was powershell autocompletion support, so I forked clikt and made PowershellCompletionGenerator.kt working.
The powershell autocompletion support includes PowershellCompletionTest.kt in my fork of clikt repo and it passes.
But in addition to that, on bbl repo side, we implemented unit test and E2E test.
bbl E2W test is done by compiled and linked Kolint/Native executable binary using script input/output testing utilizing TabExpansion2.
E2E test is run by test kitchen and latest CI result for the powershell test can be found in github action of bbl
And finally, bbl v2.0 is released with powershell completion support included, so anyone who wants to test it out can test by installing bbl on windows:
with scoop:
or msi installer
Then run following:
Then
bbl stab tab will auto-completebbl search