diff options
| author | Eyal Posener <[email protected]> | 2017-05-06 22:21:03 +0300 |
|---|---|---|
| committer | GitHub <[email protected]> | 2017-05-06 22:21:03 +0300 |
| commit | c26ef096c7990a5ae97b503545fd76ff6df388d6 (patch) | |
| tree | d0180b667269b985d15520f3b2e1aafc9292af6e /cmd/install/root.go | |
| parent | 2b6aed2b1e974a733c0dc614a9617c33a54c208c (diff) | |
| parent | 404634e843081e7010260bd95006b84d6c40a8fd (diff) | |
Merge pull request #4 from posener/doc
Doc
Diffstat (limited to 'cmd/install/root.go')
| -rw-r--r-- | cmd/install/root.go | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/cmd/install/root.go b/cmd/install/root.go new file mode 100644 index 0000000..66e23b3 --- /dev/null +++ b/cmd/install/root.go @@ -0,0 +1,29 @@ +package install + +import "os" + +type root struct{} + +func (r root) Install(cmd string, bin string) error { + completeLink := getBashCompletionDLink(cmd) + err := r.Uninstall(cmd, bin) + if err != nil { + return err + } + return os.Symlink(bin, completeLink) +} + +func (root) Uninstall(cmd string, bin string) error { + completeLink := getBashCompletionDLink(cmd) + if _, err := os.Stat(completeLink); err == nil { + err := os.Remove(completeLink) + if err != nil { + return err + } + } + return nil +} + +func getBashCompletionDLink(cmd string) string { + return "/etc/bash_completion.d/" + cmd +} |
