Skip to content

feat(fish): implement ShellCompDirectiveFilterDirs#2372

Open
thaJeztah wants to merge 1 commit intospf13:mainfrom
thaJeztah:fish_ShellCompDirectiveFilterDir
Open

feat(fish): implement ShellCompDirectiveFilterDirs#2372
thaJeztah wants to merge 1 commit intospf13:mainfrom
thaJeztah:fish_ShellCompDirectiveFilterDir

Conversation

@thaJeztah
Copy link
Contributor

Fish supports directory-only completions through __fish_complete_directories, but Cobra's generated completion script treated this directive as unsupported.

Use Fish's native directory completion when ShellCompDirectiveFilterDirs is set.

Fish supports directory-only completions through `__fish_complete_directories`,
but Cobra's generated completion script treated this directive as unsupported.

Use Fish's native directory completion when `ShellCompDirectiveFilterDirs` is set.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
@thaJeztah
Copy link
Contributor Author

Failure is unrelated to my changes, but perhaps GolangCi-lint was updated;

  Error: completions.go:958:24: G703: Path traversal via taint analysis (gosec)
  		f, err := os.OpenFile(path,
  		                     ^

* `BashCompSubdirsInDir` (filtering by directory)
* The functions corresponding to the above annotations are consequently not supported and will be ignored for `fish`:
* `MarkFlagFilename()` and `MarkPersistentFlagFilename()` (filtering by file extension)
* `MarkFlagDirname()` and `MarkPersistentFlagDirname()` (filtering by directory)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm unsure why this line was removed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I need to double check when I'm back at my computer, but I think the flow was; these options set a "bash" annotation on the flag, but the code further down converts that to setting autocompletion for the flag, using the ShellCompDirectiveFilterDirs directive.

So they were ignored because that directive wasn't functional 😅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants