-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
56 lines (48 loc) · 1.17 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
package main
import (
"github.com/git-zjx/git-local-stats/stats"
"github.com/spf13/cobra"
"log"
)
var CmdScan = &cobra.Command{
Use: "add",
Short: "Add and Scan an folder",
Long: "Add and Scan that folder and its subdirectories for repositories to scan, Example: git-stats scan /path/to/folder",
Run: scanRun,
}
var CmdStats = &cobra.Command{
Use: "stats",
Short: "Generate a CLI stats graph for the passed email",
Long: "Generate a CLI stats graph representing the last 6 months of activity for the passed email, Example: git-stats stats [email protected]",
Run: statsRun,
}
func scanRun(cmd *cobra.Command, args []string) {
if len(args) <= 0 {
return
}
for _, arg := range args {
stats.Scan(arg)
}
}
func statsRun(cmd *cobra.Command, args []string) {
if len(args) <= 0 {
return
}
email := args[0]
stats.Print(email)
}
var rootCmd = &cobra.Command{
Use: "git-stats",
Short: "git-stats: An tool for Git local stats.",
Long: `git-stats: An tool for Git local stats.`,
Version: "1.0",
}
func init() {
rootCmd.AddCommand(CmdScan)
rootCmd.AddCommand(CmdStats)
}
func main() {
if err := rootCmd.Execute(); err != nil {
log.Fatal(err)
}
}