mirror of
https://git.uploadfilter24.eu/lerentis/terraform-provider-gitea.git
synced 2024-11-06 02:38:13 +00:00
b4859cda6b
Bumps [github.com/hashicorp/terraform-plugin-docs](https://github.com/hashicorp/terraform-plugin-docs) from 0.7.0 to 0.13.0. - [Release notes](https://github.com/hashicorp/terraform-plugin-docs/releases) - [Changelog](https://github.com/hashicorp/terraform-plugin-docs/blob/main/CHANGELOG.md) - [Commits](https://github.com/hashicorp/terraform-plugin-docs/compare/v0.7.0...v0.13.0) --- updated-dependencies: - dependency-name: github.com/hashicorp/terraform-plugin-docs dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com>
37 lines
825 B
Go
37 lines
825 B
Go
package install
|
|
|
|
import "fmt"
|
|
|
|
// (un)install in bash
|
|
// basically adds/remove from .bashrc:
|
|
//
|
|
// complete -C </path/to/completion/command> <command>
|
|
type bash struct {
|
|
rc string
|
|
}
|
|
|
|
func (b bash) IsInstalled(cmd, bin string) bool {
|
|
completeCmd := b.cmd(cmd, bin)
|
|
return lineInFile(b.rc, completeCmd)
|
|
}
|
|
|
|
func (b bash) Install(cmd, bin string) error {
|
|
if b.IsInstalled(cmd, bin) {
|
|
return fmt.Errorf("already installed in %s", b.rc)
|
|
}
|
|
completeCmd := b.cmd(cmd, bin)
|
|
return appendToFile(b.rc, completeCmd)
|
|
}
|
|
|
|
func (b bash) Uninstall(cmd, bin string) error {
|
|
if !b.IsInstalled(cmd, bin) {
|
|
return fmt.Errorf("does not installed in %s", b.rc)
|
|
}
|
|
|
|
completeCmd := b.cmd(cmd, bin)
|
|
return removeFromFile(b.rc, completeCmd)
|
|
}
|
|
|
|
func (bash) cmd(cmd, bin string) string {
|
|
return fmt.Sprintf("complete -C %s %s", bin, cmd)
|
|
}
|