forge/findConfig.go

58 lines
1006 B
Go

package main
import "go.wit.com/log"
// retuns true if nothing was done
func findConfig() bool {
var done bool = false
if argv.Find != nil {
if argv.Find.Mine {
findConfigMine()
done = true
}
if argv.Find.All {
findConfigAll()
done = true
}
}
if !done {
findConfigAll()
done = true
}
return done
}
// finds config repos that are writable
func findConfigMine() {
all := me.forge.Config.SortByGoPath()
for all.Scan() {
r := all.Next()
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() {
all := me.forge.Config.SortByGoPath()
for all.Scan() {
r := all.Next()
gopath := r.GoPath
if r.GetDirectory() {
continue
}
if me.forge.Config.IsWritable(gopath) {
log.Info("mine:", gopath)
me.foundPaths = append(me.foundPaths, gopath)
continue
}
}
}