-
Notifications
You must be signed in to change notification settings - Fork 11
/
main.go
61 lines (50 loc) · 1.33 KB
/
main.go
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
55
56
57
58
59
60
61
package main
import (
"flag"
"fmt"
"os"
"strings"
"time"
"github.com/briandowns/spinner"
"github.com/gookit/color"
)
func main() {
var email, path string
var sinceflag, untilflag string
flag.StringVar(&sinceflag, "since", "", "start date")
flag.StringVar(&untilflag, "until", "", "end date")
flag.StringVar(&email, "email", strings.TrimSpace(getGlobalEmailFromGit()), "you Git email")
flag.StringVar(&path, "path", "", "folder path to scan")
flag.Parse()
if path == "" {
fmt.Fprintln(os.Stderr, color.Red.Sprintf("gitcs: please provide a folder path to scan"))
os.Exit(1)
}
b, err := setTimeFlags(sinceflag, untilflag)
if err != nil {
fmt.Fprint(os.Stderr, color.Red.Sprintf("gitcs: %s\n", err.Error()))
os.Exit(1)
}
if valid := isValidEmail(email); !valid {
fmt.Fprintln(os.Stderr, color.Red.Sprintf("gitcs: invalid 'email' address"))
os.Exit(1)
}
s := spinner.New(spinner.CharSets[6], 100*time.Millisecond, spinner.WithSuffix(" loading..."))
s.Color("green")
s.Start()
defer s.Stop()
repos, err := scanGitFolders(path)
if err != nil {
fmt.Fprint(os.Stderr, color.Red.Sprintf("\ngitcs: error: %s\n", err.Error()))
s.Stop()
os.Exit(1)
}
commits := processRepos(repos, email, *b)
fmt.Print("\n\n")
printTable(commits, *b)
fmt.Print("\n\n")
}
type Boundary struct {
Since time.Time
Until time.Time
}