Skip to content

Commit

Permalink
[feature] tab complete (#173)
Browse files Browse the repository at this point in the history
  • Loading branch information
Eduardo Lopez authored Oct 17, 2018
1 parent 634905a commit 5e638dd
Show file tree
Hide file tree
Showing 361 changed files with 28,659 additions and 3,753 deletions.
232 changes: 121 additions & 111 deletions Gopkg.lock

Large diffs are not rendered by default.

4 changes: 0 additions & 4 deletions Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@
branch = "master"
name = "github.com/hashicorp/hcl"

[[constraint]]
name = "github.com/pkg/errors"
branch = "master"

[[constraint]]
name = "github.com/hashicorp/terraform"
version = "0.11.7"
Expand Down
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,32 @@ The basic workflow is –
2. run `fogg apply` to code generate
3. use the generated Makefiles to run your Terraform commands

### Enabling shell autocompletion

#### bash

##### Linux
```
# Might need to install bash-completion on CentOS
yum install bash-completion
# install completion
echo "source <(fogg completion bash)" >> ~/.bashrc
```

##### Mac
```
## If running Bash 3.2 included with macOS
brew install bash-completion
## or, if running Bash 4.1+
brew install bash-completion@2
# install completion
fogg completion bash > $(brew --prefix)/etc/bash_completion.d/fogg
```

#### zsh
You can add the file generated by `fogg completion zsh` to a directory in your $fpath.

## Design Principles

### Convention over Configuration
Expand Down
37 changes: 37 additions & 0 deletions cmd/completion.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package cmd

import (
"os"

"github.com/spf13/cobra"
)

var completionCmd = &cobra.Command{
Use: "completion",
Short: "",
SilenceUsage: true,
}

var bashCmd = &cobra.Command{
Use: "bash",
Short: "Generates bash completion",
Long: "Generates bash completion",
RunE: func(cmd *cobra.Command, args []string) error {
return rootCmd.GenBashCompletion(os.Stdout)
},
}

var zshCmd = &cobra.Command{
Use: "zsh",
Short: "Generates zsh completion",
Long: "Generates zsh completion",
RunE: func(cmd *cobra.Command, args []string) error {
return rootCmd.GenZshCompletion(os.Stdout)
},
}

func init() {
rootCmd.AddCommand(completionCmd)
completionCmd.AddCommand(bashCmd)
completionCmd.AddCommand(zshCmd)
}
1 change: 1 addition & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ var rootCmd = &cobra.Command{
SilenceUsage: true,
}

// Execute executes the rootCmd
func Execute() {
red := color.New(color.FgRed).SprintFunc()

Expand Down
27 changes: 27 additions & 0 deletions test
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#compdef fogg

case $state in
level1)
case $words[1] in
fogg)
_arguments '1: :(apply completion help init plan version)'
;;
*)
_arguments '*: :_files'
;;
esac
;;
level2)
case $words[2] in
completion)
_arguments '2: :(bash zsh)'
;;
*)
_arguments '*: :_files'
;;
esac
;;
*)
_arguments '*: :_files'
;;
esac
1 change: 1 addition & 0 deletions vendor/github.com/Masterminds/sprig/.travis.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion vendor/github.com/Masterminds/sprig/crypto.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion vendor/github.com/Masterminds/sprig/defaults.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions vendor/github.com/Masterminds/sprig/dict.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

216 changes: 1 addition & 215 deletions vendor/github.com/Masterminds/sprig/doc.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 5e638dd

Please sign in to comment.