Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate cobra's v2 bash completions #141

Merged
merged 1 commit into from
Apr 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmd/completion.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ with shell name as argument, output completion for the shell to standard output.
}
switch args[0] {
case "bash":
return rootCmd.GenBashCompletion(os.Stdout)
return rootCmd.GenBashCompletionV2(os.Stdout, false)
case "fish":
return rootCmd.GenFishCompletion(os.Stdout, false)
case "zsh":
Expand Down
4 changes: 2 additions & 2 deletions internal/completion/completion.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func makeBashCompletionFileIfNeeded(cmd *cobra.Command) {

path := bashCompletionFilePath()
bashCompletion := new(bytes.Buffer)
if err := cmd.GenBashCompletion(bashCompletion); err != nil {
if err := cmd.GenBashCompletionV2(bashCompletion, false); err != nil {
print.Err(fmt.Errorf("can not generate bash completion content: %w", err))
return
}
Expand Down Expand Up @@ -167,7 +167,7 @@ func hasSameBashCompletionContent(cmd *cobra.Command) bool {
}

currentBashCompletion := new(bytes.Buffer)
if err := cmd.GenBashCompletion(currentBashCompletion); err != nil {
if err := cmd.GenBashCompletionV2(currentBashCompletion, false); err != nil {
return false
}
if !strings.Contains(string(bashCompletionFileInLocal), currentBashCompletion.String()) {
Expand Down
Loading