From 7281592493d5a64222c2261fce7d9cb4205f88a5 Mon Sep 17 00:00:00 2001 From: Tai Groot Date: Sun, 19 Jun 2022 15:41:13 -0600 Subject: [PATCH] refactor --- main.go => gico.go | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) rename main.go => gico.go (61%) diff --git a/main.go b/gico.go similarity index 61% rename from main.go rename to gico.go index 5d401f5..6598d70 100644 --- a/main.go +++ b/gico.go @@ -1,19 +1,16 @@ -package main +package gico import ( "flag" "fmt" "os" "time" + + "github.com/taigrr/gico/ui" ) type Month string -var months = []Month{"Jan", "Feb", "Mar", - "Apr", "May", "Jun", - "Jul", "Aug", "Sep", - "Oct", "Nov", "Dec"} - var days [366]int func init() { @@ -34,7 +31,7 @@ func main() { case "graph": printGraph() case "interactive": - interactiveGraph() + ui.InteractiveGraph() case "loadRepo": loadRepo() default: @@ -43,10 +40,12 @@ func main() { } type Commit struct { - LOC int `json:"loc"` - Message string `json:"message"` - TimeStamp time.Time `json:"ts"` - Author string `json:"author"` + LOC int `json:"loc,omitempty"` + Message string `json:"message,omitempty"` + TimeStamp time.Time `json:"ts,omitempty"` + Author string `json:"author,omitempty"` + Repo string `json:"repo,omitempty"` + Path string `json:"path,omitempty"` } type DataSet map[time.Time]WorkDay @@ -54,17 +53,22 @@ type DataSet map[time.Time]WorkDay type WorkDay struct { Day time.Time `json:"day"` Count int `json:"count"` - Message string `json:"message,omitempty"` Commits []Commit `json:"commits,omitempty"` } +func NewCommit(Author, Message, Repo, Path string, LOC int) Commit { + ci := Commit{Message: Message, + Author: Author, LOC: LOC, TimeStamp: time.Now(), + Repo: Repo, Path: Path} + return ci +} + func loadRepo() { } func readCommitDB() DataSet { ds := DataSet{} - ds = append(ds, return ds } func printHelp() { @@ -73,7 +77,7 @@ func printHelp() { func increment() { commits := readCommitDB() - + // crea fmt.Printf("%v\n", commits) }