Skip to content

Commit

Permalink
cmd: add completion command for bash completion
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Buchanan authored and adamstruck committed Apr 9, 2018
1 parent 59a452f commit ceb2629
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 12 deletions.
26 changes: 26 additions & 0 deletions cmd/completion.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package cmd

import (
"os"

"github.com/spf13/cobra"
)

var completionCmd = &cobra.Command{
Use: "completion",
Short: "Generate shell completion code",
}

var bash = &cobra.Command{
Use: "bash",
Short: "Generate bash completion code",
Long: `This command generates bash CLI completion code.
Add "source <(funnel completion bash)" to your bash profile.`,
Run: func(cmd *cobra.Command, args []string) {
RootCmd.GenBashCompletion(os.Stdout)
},
}

func init() {
completionCmd.AddCommand(bash)
}
11 changes: 0 additions & 11 deletions cmd/gendocs.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package cmd

import (
"os"

"github.com/spf13/cobra"
"github.com/spf13/cobra/doc"
)
Expand All @@ -15,12 +13,3 @@ var genMarkdownCmd = &cobra.Command{
return doc.GenMarkdownTree(RootCmd, "./funnel-cmd-docs")
},
}

var genBashCompletionCmd = &cobra.Command{
Use: "genbash",
Short: "generate bash completions for the funnel commands",
Hidden: true,
Run: func(cmd *cobra.Command, args []string) {
RootCmd.GenBashCompletion(os.Stdout)
},
}
2 changes: 1 addition & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func init() {
RootCmd.AddCommand(aws.Cmd)
RootCmd.AddCommand(examples.Cmd)
RootCmd.AddCommand(gce.Cmd)
RootCmd.AddCommand(genBashCompletionCmd)
RootCmd.AddCommand(completionCmd)
RootCmd.AddCommand(genMarkdownCmd)
RootCmd.AddCommand(node.NewCommand())
RootCmd.AddCommand(run.Cmd)
Expand Down

0 comments on commit ceb2629

Please sign in to comment.