forge/findConfig.go

55 lines
946 B
Go
Raw Normal View History

2024-12-05 12:29:47 -06:00
package main
import "go.wit.com/log"
// retuns true if nothing was done
2024-12-27 04:36:29 -06:00
func findConfig(fargv *FindCmd) {
if fargv == nil {
findConfigAll()
return
}
if fargv.Mine {
findConfigMine()
return
2024-12-05 12:29:47 -06:00
}
2024-12-27 04:36:29 -06:00
if fargv.All {
findConfigAll()
2024-12-27 04:36:29 -06:00
return
}
2024-12-27 04:36:29 -06:00
findConfigAll()
2024-12-05 12:29:47 -06:00
}
// finds config repos that are writable
func findConfigMine() {
2024-12-11 19:32:04 -06:00
all := me.forge.Config.SortByGoPath()
for all.Scan() {
r := all.Next()
2024-12-05 12:29:47 -06:00
gopath := r.GoPath
if r.GetDirectory() {
continue
}
if me.forge.Config.IsWritable(gopath) {
log.Info("mine:", gopath)
me.foundPaths = append(me.foundPaths, gopath)
continue
}
}
}
// get everything in your config
func findConfigAll() {
2024-12-11 19:32:04 -06:00
all := me.forge.Config.SortByGoPath()
for all.Scan() {
r := all.Next()
2024-12-05 12:29:47 -06:00
gopath := r.GoPath
if r.GetDirectory() {
continue
}
if me.forge.Config.IsWritable(gopath) {
log.Info("mine:", gopath)
me.foundPaths = append(me.foundPaths, gopath)
continue
}
}
}