diff --git a/caplets/env.go b/caplets/env.go index 7d5350c9..58597eb2 100644 --- a/caplets/env.go +++ b/caplets/env.go @@ -8,16 +8,18 @@ import ( ) const ( - EnvVarName = "CAPSPATH" - Suffix = ".cap" - InstallArchive = "https://github.com/bettercap/caplets/archive/master.zip" - InstallBase = "/usr/local/share/bettercap/" - InstallPathArchive = "/usr/local/share/bettercap/caplets-master/" - InstallPath = "/usr/local/share/bettercap/caplets/" + EnvVarName = "CAPSPATH" + Suffix = ".cap" + InstallArchive = "https://github.com/bettercap/caplets/archive/master.zip" + InstallBase = "/usr/local/share/bettercap/" ) var ( + InstallPathArchive = filepath.Join(InstallBase, "caplets-master") + InstallPath = filepath.Join(InstallBase, "caplets") + LoadPaths = []string{ + "./", "./caplets/", InstallPath, } diff --git a/caplets/manager.go b/caplets/manager.go index e93ff733..b2864ece 100644 --- a/caplets/manager.go +++ b/caplets/manager.go @@ -19,9 +19,7 @@ var ( func List() []Caplet { caplets := make([]Caplet, 0) - cwd, _ := filepath.Abs(".") - - for _, searchPath := range append([]string{cwd}, LoadPaths...) { + for _, searchPath := range LoadPaths { files, _ := filepath.Glob(searchPath + "/*" + Suffix) files2, _ := filepath.Glob(searchPath + "/*/*" + Suffix) @@ -54,15 +52,12 @@ func Load(name string) (error, *Caplet) { return nil, caplet } - names := []string{name} + names := []string{} if !strings.HasSuffix(name, Suffix) { - names = append(names, name+Suffix) + name += Suffix } for _, path := range LoadPaths { - if !strings.HasSuffix(name, Suffix) { - name += Suffix - } names = append(names, filepath.Join(path, name)) } diff --git a/modules/caplets.go b/modules/caplets.go index 890e7009..af14ccb0 100644 --- a/modules/caplets.go +++ b/modules/caplets.go @@ -98,7 +98,7 @@ func (c *CapletsModule) Paths() error { colNames := []string{ "Path", } - rows := [][]string{[]string{"."}} + rows := [][]string{} for _, path := range caplets.LoadPaths { rows = append(rows, []string{path})