diff options
| author | Eyal Posener <[email protected]> | 2017-05-06 22:06:49 +0300 |
|---|---|---|
| committer | Eyal Posener <[email protected]> | 2017-05-06 22:15:15 +0300 |
| commit | 703dd6ebc30f7c6f5a5c02e07a307e0e34d9c2c2 (patch) | |
| tree | 6efd5f6d1205eb6188193c86f5dd1e256b8996c5 /cmd/install/root.go | |
| parent | 9963a854946be0603f9e79ccba0a8b2688b20053 (diff) | |
improve docs
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 +} |
