summaryrefslogtreecommitdiff
path: root/findConfig.go
blob: 6703adfbdb9b59bacf344d953d5f228cccef7b6e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package main

import "go.wit.com/log"

// retuns true if nothing was done
func findConfig(fargv *FindCmd) {
	if fargv == nil {
		findConfigAll()
		return
	}
	if fargv.Mine {
		findConfigMine()
		return
	}
	if fargv.All {
		findConfigAll()
		return
	}
	findConfigAll()
}

// 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
		}
	}
}