summaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
Diffstat (limited to 'main.go')
-rw-r--r--main.go53
1 files changed, 34 insertions, 19 deletions
diff --git a/main.go b/main.go
index fd85bd7..7a6f4c1 100644
--- a/main.go
+++ b/main.go
@@ -3,12 +3,10 @@ package main
import (
"os"
"path/filepath"
- "strings"
"go.wit.com/dev/alexflint/arg"
"go.wit.com/gui"
"go.wit.com/lib/gui/repolist"
- "go.wit.com/lib/gui/repostatus"
"go.wit.com/lib/gui/shell"
"go.wit.com/lib/protobuf/forgepb"
"go.wit.com/log"
@@ -30,16 +28,10 @@ func main() {
os.Exit(0)
}
- // use ~/go/src unless we find a go.work file in a parent directory
- goSrcPath, err := forgepb.FindGoSrc()
- if err != nil {
- log.Info(err)
- os.Exit(-1)
- }
- if goSrcPath != "" {
- os.Setenv("REPO_WORK_PATH", goSrcPath)
-
- }
+ // load the ~/.config/forge/ config
+ forge := forgepb.Init()
+ forge.ConfigPrintTable()
+ os.Setenv("REPO_WORK_PATH", forge.GetGoSrc())
if argv.Repo == "" {
// if there isn't anything else, just exit here
@@ -76,18 +68,29 @@ func main() {
}
}
- // sets up gui stuff. not working yet
- b := gui.RawBox()
- rv = repolist.AutotypistView(b)
+ // testing gui idea
+ myGui := gui.New()
+ // myGui.Default()
+
+ rv := repolist.Init(forge, myGui)
+ rv.Enable()
+
+ rv.ScanRepositories()
// if the user defined a repo, attempt to download it now
if argv.Repo != "" {
os.Setenv("REPO_AUTO_CLONE", "true")
- newr, err := rv.NewRepo(argv.Repo)
+ // pb, _ := forge.NewGoPath(argv.Repo)
+ pb, err := forge.Clone(argv.Repo)
if err != nil {
log.Info("could not download:", err)
os.Exit(-1)
}
+ newr, err := rv.AddRepo(pb)
+ if err != nil {
+ log.Info("AddRepo() failed", err)
+ os.Exit(-1)
+ }
if argv.Recursive || argv.Pull || argv.RedoGoMod {
log.Info("repo already cloned", filepath.Join(goSrcPath, argv.Repo))
// there is more to do
@@ -115,7 +118,7 @@ func main() {
os.Setenv("REPO_AUTO_CLONE", "false")
// look recursively in your working directory for git repos
- totalcount := scanForRepos(goSrcPath)
+ totalcount := forge.Repos.Len()
// if --git-pull, run git pull on everything here
if argv.Pull {
@@ -153,7 +156,12 @@ func main() {
os.Setenv("REPO_AUTO_CLONE", "true")
godep := newr.Status.GetGoDeps()
for gopath, version := range godep {
- repo, err := rv.NewRepo(gopath)
+ pb, err := forge.Clone(gopath)
+ if err != nil {
+ log.Info("could not download:", err)
+ os.Exit(-1)
+ }
+ repo, err := rv.AddRepo(pb)
if err != nil {
log.Info("git clone failed for", gopath, version)
continue
@@ -190,6 +198,7 @@ func main() {
log.Info("Finished go-clone for", argv.Repo)
}
+/*
func scanForRepos(goSrcPath string) int {
var count int
log.Info("scanning for repo in:", filepath.Join(goSrcPath, argv.Repo))
@@ -200,7 +209,13 @@ func scanForRepos(goSrcPath string) int {
gopath := strings.TrimPrefix(path, goSrcPath)
gopath = strings.Trim(gopath, "/")
// log.Info("Also should add:", gopath)
- rv.NewRepo(gopath)
+ pb, err := forge.Clone(gopath)
+ if err != nil {
+ log.Info("could not download:", err)
+ os.Exit(-1)
+ }
+ repo, err := rv.AddRepo(pb)
}
return count
}
+*/