summaryrefslogtreecommitdiff
path: root/configfile.go
diff options
context:
space:
mode:
Diffstat (limited to 'configfile.go')
-rw-r--r--configfile.go36
1 files changed, 36 insertions, 0 deletions
diff --git a/configfile.go b/configfile.go
new file mode 100644
index 0000000..a339d70
--- /dev/null
+++ b/configfile.go
@@ -0,0 +1,36 @@
+package repolist
+
+import (
+ "io/ioutil"
+ "os"
+ "path/filepath"
+ "strings"
+
+ "go.wit.com/log"
+)
+
+func (v *RepoList) InitRepoList(cfgfile string) {
+ lines := parsecfg(cfgfile)
+ for _, line := range lines {
+ log.Verbose("repo =", line)
+ line = strings.TrimSpace(line)
+ if strings.HasPrefix(line, "#") {
+ continue
+ }
+ parts := strings.Split(line, " ")
+ if len(parts) > 0 {
+ path := parts[0]
+ v.NewRepo(path)
+ }
+ }
+}
+
+func parsecfg(f string) []string {
+ homeDir, _ := os.UserHomeDir()
+ cfgfile := filepath.Join(homeDir, f)
+ content, _ := ioutil.ReadFile(cfgfile)
+ out := string(content)
+ out = strings.TrimSpace(out)
+ lines := strings.Split(out, "\n")
+ return lines
+}