summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--indexHtml.go4
-rw-r--r--main.go73
2 files changed, 7 insertions, 70 deletions
diff --git a/indexHtml.go b/indexHtml.go
index 48a1a01..c653221 100644
--- a/indexHtml.go
+++ b/indexHtml.go
@@ -4,6 +4,8 @@ import (
"fmt"
"net/http"
"strings"
+
+ "go.wit.com/lib/cobol"
)
func indexHeader(w http.ResponseWriter) {
@@ -102,7 +104,7 @@ func indexBodyRepo(w http.ResponseWriter, gourl string, giturl string, desc stri
if repo, ok := gitMap[gourl]; ok {
version = repo.GetLastTag()
age := repo.NewestAge()
- vtime = formatDuration(age)
+ vtime = cobol.FormatDuration(age)
dver = repo.GetDevelVersion()
}
// log.Info("gopath", gourl, "dur", vtime, "version", version)
diff --git a/main.go b/main.go
index 1a2db21..a5da179 100644
--- a/main.go
+++ b/main.go
@@ -5,7 +5,6 @@ import (
"fmt"
"net/http"
"strings"
- "time"
"go.wit.com/lib/gui/prep"
"go.wit.com/lib/protobuf/forgepb"
@@ -35,7 +34,7 @@ var LIBDIR string = "/var/lib/gowebd/"
func main() {
me = new(mainType)
- me.sh = prep.Bash(&argv) // adds shell auto complete to go-args
+ me.sh = prep.Autocomplete(&argv) // adds shell auto complete to go-args
if argv.RepoMap != "" {
REPOMAP = argv.RepoMap
@@ -47,7 +46,7 @@ func main() {
gitMap = make(map[string]*gitpb.Repo)
repoMap = make(map[string]string)
- me.forge = forgepb.Init()
+ me.forge, _ = forgepb.Init()
// parse the repomap file
readRepomap()
@@ -102,71 +101,7 @@ func newMakeRepomap() (string, error) {
log.Info(repo.Namespace, repo.URL)
}
- makePullTable(updatepb)
+ footer := updatepb.PrintGowebdTable()
+ log.Info(footer)
return "new dynamic repomap!", nil
}
-
-func makePullTable(pb *gitpb.Repos) {
- t := pb.NewTable("pullTable")
- t.NewUuid()
-
- var col *gitpb.RepoFunc
- // var col int
-
- col = t.AddNamespace()
- col.Width = 30
-
- col = t.AddMasterVersion()
- // col.SetTitle("mver")
- col.Width = 15
-
- col = t.AddStringFunc("Tags", func(r *gitpb.Repo) string {
- if r.Tags == nil {
- return "nil"
- }
- log.Infof("repo: %v\n", r)
- return log.Sprintf("len(%d)", r.Tags.Len())
- })
- col.Width = 9
-
- col = t.AddStringFunc("cur tag", func(r *gitpb.Repo) string {
- if r.CurrentTag == nil {
- return "nil"
- }
- return "ok"
- })
- col.Width = 9
-
- col = t.AddDevelVersion()
- col.Width = 15
-
- col = t.AddFullPath()
- col.Width = -1
-
- t.PrintTable()
-}
-
-func formatDuration(d time.Duration) string {
- seconds := int(d.Seconds()) % 60
- minutes := int(d.Minutes()) % 60
- hours := int(d.Hours()) % 24
- days := int(d.Hours()) / 24
-
- result := ""
- if days > 0 {
- result += fmt.Sprintf("%dd ", days)
- return result
- }
- if hours > 0 {
- result += fmt.Sprintf("%dh ", hours)
- return result
- }
- if minutes > 0 {
- result += fmt.Sprintf("%dm ", minutes)
- return result
- }
- if seconds > 0 {
- result += fmt.Sprintf("%ds", seconds)
- }
- return result
-}