mirror of
https://github.com/bettercap/bettercap
synced 2025-08-20 13:33:21 -07:00
misc: small fix or general refactoring i did not bother commenting
This commit is contained in:
parent
91f074c3ee
commit
654585ff1f
3 changed files with 12 additions and 15 deletions
|
@ -12,12 +12,14 @@ const (
|
||||||
Suffix = ".cap"
|
Suffix = ".cap"
|
||||||
InstallArchive = "https://github.com/bettercap/caplets/archive/master.zip"
|
InstallArchive = "https://github.com/bettercap/caplets/archive/master.zip"
|
||||||
InstallBase = "/usr/local/share/bettercap/"
|
InstallBase = "/usr/local/share/bettercap/"
|
||||||
InstallPathArchive = "/usr/local/share/bettercap/caplets-master/"
|
|
||||||
InstallPath = "/usr/local/share/bettercap/caplets/"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
InstallPathArchive = filepath.Join(InstallBase, "caplets-master")
|
||||||
|
InstallPath = filepath.Join(InstallBase, "caplets")
|
||||||
|
|
||||||
LoadPaths = []string{
|
LoadPaths = []string{
|
||||||
|
"./",
|
||||||
"./caplets/",
|
"./caplets/",
|
||||||
InstallPath,
|
InstallPath,
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,9 +19,7 @@ var (
|
||||||
|
|
||||||
func List() []Caplet {
|
func List() []Caplet {
|
||||||
caplets := make([]Caplet, 0)
|
caplets := make([]Caplet, 0)
|
||||||
cwd, _ := filepath.Abs(".")
|
for _, searchPath := range LoadPaths {
|
||||||
|
|
||||||
for _, searchPath := range append([]string{cwd}, LoadPaths...) {
|
|
||||||
files, _ := filepath.Glob(searchPath + "/*" + Suffix)
|
files, _ := filepath.Glob(searchPath + "/*" + Suffix)
|
||||||
files2, _ := filepath.Glob(searchPath + "/*/*" + Suffix)
|
files2, _ := filepath.Glob(searchPath + "/*/*" + Suffix)
|
||||||
|
|
||||||
|
@ -54,15 +52,12 @@ func Load(name string) (error, *Caplet) {
|
||||||
return nil, caplet
|
return nil, caplet
|
||||||
}
|
}
|
||||||
|
|
||||||
names := []string{name}
|
names := []string{}
|
||||||
if !strings.HasSuffix(name, Suffix) {
|
|
||||||
names = append(names, name+Suffix)
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, path := range LoadPaths {
|
|
||||||
if !strings.HasSuffix(name, Suffix) {
|
if !strings.HasSuffix(name, Suffix) {
|
||||||
name += Suffix
|
name += Suffix
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for _, path := range LoadPaths {
|
||||||
names = append(names, filepath.Join(path, name))
|
names = append(names, filepath.Join(path, name))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -98,7 +98,7 @@ func (c *CapletsModule) Paths() error {
|
||||||
colNames := []string{
|
colNames := []string{
|
||||||
"Path",
|
"Path",
|
||||||
}
|
}
|
||||||
rows := [][]string{[]string{"."}}
|
rows := [][]string{}
|
||||||
|
|
||||||
for _, path := range caplets.LoadPaths {
|
for _, path := range caplets.LoadPaths {
|
||||||
rows = append(rows, []string{path})
|
rows = append(rows, []string{path})
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue