feature: Add goctl completion (#1505)

* feature: Add `goctl completion`

* Update const

Co-authored-by: anqiansong <anqiansong@bytedance.com>
This commit is contained in:
anqiansong
2022-02-08 10:50:21 +08:00
committed by GitHub
parent bb75cc796e
commit 8bd89a297a
5 changed files with 166 additions and 3 deletions

View File

@@ -15,9 +15,10 @@ import (
// NL defines a new line
const (
NL = "\n"
goctlDir = ".goctl"
gitDir = ".git"
NL = "\n"
goctlDir = ".goctl"
gitDir = ".git"
autoCompleteDir = ".auto_complete"
)
var goctlHome string
@@ -93,6 +94,16 @@ func GetGitHome() (string, error) {
return filepath.Join(goctlH, gitDir), nil
}
// GetAutoCompleteHome returns the auto_complete home of goctl.
func GetAutoCompleteHome() (string, error) {
goctlH, err := GetGoctlHome()
if err != nil {
return "", err
}
return filepath.Join(goctlH, autoCompleteDir), nil
}
// GetTemplateDir returns the category path value in GoctlHome where could get it by GetGoctlHome
func GetTemplateDir(category string) (string, error) {
home, err := GetGoctlHome()