forge/findConfig.go

58 lines
1006 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
func findConfig() bool {
var done bool = false
2024-12-24 01:54:33 -06:00
if argv.Find != nil {
if argv.Find.Mine {
findConfigMine()
done = true
}
if argv.Find.All {
findConfigAll()
done = true
}
2024-12-05 12:29:47 -06:00
}
if !done {
findConfigAll()
done = true
}
return done
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
}
}
}