diff options
author | Alex Pilon <apilon@hashicorp.com> | 2019-02-22 18:24:37 -0500 |
---|---|---|
committer | Alex Pilon <apilon@hashicorp.com> | 2019-02-22 18:24:37 -0500 |
commit | 15c0b25d011f37e7c20aeca9eaf461f78285b8d9 (patch) | |
tree | 255c250a5c9d4801c74092d33b7337d8c14438ff /vendor/github.com/posener/complete/cmd/install/zsh.go | |
parent | 07971ca38143c5faf951d152fba370ddcbe26ad5 (diff) | |
download | terraform-provider-statuscake-15c0b25d011f37e7c20aeca9eaf461f78285b8d9.tar.gz terraform-provider-statuscake-15c0b25d011f37e7c20aeca9eaf461f78285b8d9.tar.zst terraform-provider-statuscake-15c0b25d011f37e7c20aeca9eaf461f78285b8d9.zip |
deps: github.com/hashicorp/terraform@sdk-v0.11-with-go-modules
Updated via: go get github.com/hashicorp/terraform@sdk-v0.11-with-go-modules and go mod tidy
Diffstat (limited to 'vendor/github.com/posener/complete/cmd/install/zsh.go')
-rw-r--r-- | vendor/github.com/posener/complete/cmd/install/zsh.go | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/vendor/github.com/posener/complete/cmd/install/zsh.go b/vendor/github.com/posener/complete/cmd/install/zsh.go new file mode 100644 index 0000000..a625f53 --- /dev/null +++ b/vendor/github.com/posener/complete/cmd/install/zsh.go | |||
@@ -0,0 +1,39 @@ | |||
1 | package install | ||
2 | |||
3 | import "fmt" | ||
4 | |||
5 | // (un)install in zsh | ||
6 | // basically adds/remove from .zshrc: | ||
7 | // | ||
8 | // autoload -U +X bashcompinit && bashcompinit" | ||
9 | // complete -C </path/to/completion/command> <command> | ||
10 | type zsh struct { | ||
11 | rc string | ||
12 | } | ||
13 | |||
14 | func (z zsh) Install(cmd, bin string) error { | ||
15 | completeCmd := z.cmd(cmd, bin) | ||
16 | if lineInFile(z.rc, completeCmd) { | ||
17 | return fmt.Errorf("already installed in %s", z.rc) | ||
18 | } | ||
19 | |||
20 | bashCompInit := "autoload -U +X bashcompinit && bashcompinit" | ||
21 | if !lineInFile(z.rc, bashCompInit) { | ||
22 | completeCmd = bashCompInit + "\n" + completeCmd | ||
23 | } | ||
24 | |||
25 | return appendToFile(z.rc, completeCmd) | ||
26 | } | ||
27 | |||
28 | func (z zsh) Uninstall(cmd, bin string) error { | ||
29 | completeCmd := z.cmd(cmd, bin) | ||
30 | if !lineInFile(z.rc, completeCmd) { | ||
31 | return fmt.Errorf("does not installed in %s", z.rc) | ||
32 | } | ||
33 | |||
34 | return removeFromFile(z.rc, completeCmd) | ||
35 | } | ||
36 | |||
37 | func (zsh) cmd(cmd, bin string) string { | ||
38 | return fmt.Sprintf("complete -o nospace -C %s %s", bin, cmd) | ||
39 | } | ||