Skip to content

Commit 5f93c93

Browse files
Add support for fish completion (#1201)
Co-authored-by: Sascha Grunert <[email protected]>
1 parent d4ebf99 commit 5f93c93

File tree

4 files changed

+21
-13
lines changed

4 files changed

+21
-13
lines changed

Diff for: .goreleaser.yml

+2
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@ brews:
9292
(bash_completion/"golangci-lint").write output
9393
output = Utils.popen_read("#{bin}/golangci-lint completion zsh")
9494
(zsh_completion/"_golangci-lint").write output
95+
output = Utils.popen_read("#{bin}/golangci-lint completion fish")
96+
(fish_completion/"eksctl.fish").write output
9597
prefix.install_metafiles
9698
test: |
9799
system "#{bin}/golangci-lint --version"

Diff for: go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ require (
4545
github.com/sirupsen/logrus v1.6.0
4646
github.com/sonatard/noctx v0.0.1
4747
github.com/sourcegraph/go-diff v0.6.0
48-
github.com/spf13/cobra v1.0.0
48+
github.com/spf13/cobra v1.0.1-0.20200916152758-7f8e83d9366a
4949
github.com/spf13/pflag v1.0.5
5050
github.com/spf13/viper v1.7.1
5151
github.com/ssgreg/nlreturn/v2 v2.1.0

Diff for: go.sum

+2-12
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: pkg/commands/completion.go

+16
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,13 @@ func (e *Executor) initCompletion() {
2828
RunE: e.executeZshCompletion,
2929
}
3030
completionCmd.AddCommand(zshCmd)
31+
32+
fishCmd := &cobra.Command{
33+
Use: "fish",
34+
Short: "Output fish completion script",
35+
RunE: e.executeFishCompletion,
36+
}
37+
completionCmd.AddCommand(fishCmd)
3138
}
3239

3340
func (e *Executor) executeBashCompletion(cmd *cobra.Command, args []string) error {
@@ -51,3 +58,12 @@ func (e *Executor) executeZshCompletion(cmd *cobra.Command, args []string) error
5158

5259
return nil
5360
}
61+
62+
func (e *Executor) executeFishCompletion(cmd *cobra.Command, args []string) error {
63+
err := cmd.Root().GenFishCompletion(os.Stdout, true)
64+
if err != nil {
65+
return errors.Wrap(err, "generate fish completion")
66+
}
67+
68+
return nil
69+
}

0 commit comments

Comments
 (0)