Fix plugin completion results parsing for ShellCompDirectiveFilterFileExt#4136
Conversation
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## master #4136 +/- ##
=======================================
Coverage 59.16% 59.16%
=======================================
Files 287 287
Lines 24716 24716
=======================================
Hits 14623 14623
Misses 9209 9209
Partials 884 884 |
277eabf to
aa1ac11
Compare
aa1ac11 to
4896123
Compare
| local rawResult=$(eval "${resultArray[*]}" 2> /dev/null) | ||
| local result=$(grep -v '^:[0-9]*$' <<< "$rawResult") | ||
|
|
||
| # Compose V2 completions sometimes returns returns `:8` (ShellCompDirectiveFilterFileExt) |
There was a problem hiding this comment.
If anyone else reviewing this was unfamiliar with what this means, it's a Cobra thing, and https://github.com/spf13/cobra/blob/4dd4b25de38418174a6e859e8a32eaccca32dccc/completions_test.go#L1046-L1047 is the best reference I could find for it being :8 (there's probably a better one, but that's what my search brought me to 😅).
There was a problem hiding this comment.
Thanks! I'd thought about adding some link explaining it better and then totally forgot :|
|
I'll skip merging this one for now, to have a look if we want to add Tianon's suggestions (as it's marked for cherry-picking, it makes it a bit cleaner to do the backport "in one go" instead of a PR-and-follow-up). |
There was a problem hiding this comment.
After finally realizing that the Completion ended with directive: ShellCompDirectiveFilterFileExt line actually goes to stderr: LGTM, thanks @laurazard
|
Just checking up on this; Is the suggestion from @tianon (echo -> tail) something to consider, or "too minor to bother")? #4136 (comment) |
…lterFileExt` Signed-off-by: Laura Brehm <laurabrehm@hey.com>
4896123 to
683e4bf
Compare
Compose V2 (and other plugins eventually) provide the extensions they want the shell to filter the autocompletion of files for:
The current script does not process these results correctly, and instead we just provide a
y(common beginning betweenyamlandyml)which is not the desired outcome.
- What I did
Check if the completion flag is
:8(ShellCompDirectiveFilterFileExt) and format a valid glob pattern to feed into_filedirwhen this is the case- How to verify it
Load the new completion script, and type
verify that completions are provided for files with the extension
.yamlor.yml,- Description for the changelog
- A picture of a cute animal (not mandatory but encouraged)