Skip to content

Commit

Permalink
Add support for fish completion
Browse files Browse the repository at this point in the history
  • Loading branch information
sayboras committed Jun 30, 2020
1 parent 184bbf8 commit ba05e4e
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
2 changes: 2 additions & 0 deletions go.mod
Expand Up @@ -62,3 +62,5 @@ require (
mvdan.cc/lint v0.0.0-20170908181259-adc824a0674b // indirect
mvdan.cc/unparam v0.0.0-20190720180237-d51796306d8f
)

replace github.com/spf13/cobra => github.com/VilledeMontreal/cobra v0.0.6-0.20200629203744-5782fedb5fb1
4 changes: 2 additions & 2 deletions go.sum
Expand Up @@ -23,6 +23,8 @@ github.com/OpenPeeDeeP/depguard v1.0.1 h1:VlW4R6jmBIv3/u1JNlawEvJMM4J+dPORPaZasQ
github.com/OpenPeeDeeP/depguard v1.0.1/go.mod h1:xsIw86fROiiwelg+jB2uM9PiKihMMmUx/1V+TNhjQvM=
github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6 h1:fLjPD/aNc3UIOA6tDi6QXUemppXK3P9BI7mr2hd6gx8=
github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6/go.mod h1:3eOhrUMpNV+6aFIbp5/iudMxNCF27Vw2OZgy4xEx0Fg=
github.com/VilledeMontreal/cobra v0.0.6-0.20200629203744-5782fedb5fb1 h1:b4N6UrpLCX/ClvjZnqRuTxLfLAF0+5tqWJLT2D/Zx2g=
github.com/VilledeMontreal/cobra v0.0.6-0.20200629203744-5782fedb5fb1/go.mod h1:/6GTrnGXV9HjY+aR4k0oJ5tcvakLuG6EuKReYlHNrgE=
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o=
Expand Down Expand Up @@ -344,8 +346,6 @@ github.com/spf13/afero v1.1.2 h1:m8/z1t7/fwjysjQRYbP0RD+bUIF/8tJwPdEZsI83ACI=
github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ=
github.com/spf13/cast v1.3.0 h1:oget//CVOEoFewqQxwr0Ej5yjygnqGkvggSE/gB35Q8=
github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
github.com/spf13/cobra v1.0.0 h1:6m/oheQuQ13N9ks4hubMG6BnvwOeaJrqSPLahSnczz8=
github.com/spf13/cobra v1.0.0/go.mod h1:/6GTrnGXV9HjY+aR4k0oJ5tcvakLuG6EuKReYlHNrgE=
github.com/spf13/jwalterweatherman v1.0.0 h1:XHEdyB+EcvlqZamSM4ZOMGlc93t6AcsBEu9Gc1vn7yk=
github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo=
github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
Expand Down
16 changes: 16 additions & 0 deletions pkg/commands/completion.go
Expand Up @@ -28,6 +28,13 @@ func (e *Executor) initCompletion() {
RunE: e.executeZshCompletion,
}
completionCmd.AddCommand(zshCmd)

fishCmd := &cobra.Command{
Use: "fish",
Short: "Output fish completion script",
RunE: e.executeFishCompletion,
}
completionCmd.AddCommand(fishCmd)
}

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

return nil
}

func (e *Executor) executeFishCompletion(cmd *cobra.Command, args []string) error {
err := cmd.Root().GenFishCompletion(os.Stdout, true)
if err != nil {
return errors.Wrap(err, "unable to generate fish completions: %v")
}

return nil
}

0 comments on commit ba05e4e

Please sign in to comment.