-
Notifications
You must be signed in to change notification settings - Fork 6
/
main.go
48 lines (40 loc) · 1.06 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
package main
import (
"flag"
"strings"
"./githubstat"
)
func main() {
// repository name
ownerName := flag.String("owner", "", "e.g. yshnb")
repoName := flag.String("repository", "", "e.g. github-stat-script")
target_metrics := flag.String("metrics", "", "available metrics: (star)")
flag.Parse()
var metricsRequest githubstat.MetricsRequest
switch *target_metrics {
case "issue":
metricsRequest = &githubstat.IssueMetricsRequest{}
case "star":
metricsRequest = &githubstat.StarMetricsRequest{}
case "pull_request":
metricsRequest = &githubstat.PullRequestMetricsRequest{}
default:
metricsRequest = &githubstat.DefaultMetricsRequest{}
}
parameters := flag.Args()
if len(parameters) > 0 {
repo := strings.Split(parameters[0], "/")
if *ownerName == "" && repo[0] != "" {
ownerName = &repo[0]
}
if *repoName == "" && repo[1] != "" {
repoName = &repo[1]
}
}
metricsRequest.SetParameters(&githubstat.MetricsParameters{
OwnerName: ownerName,
RepoName: repoName,
})
metrics := metricsRequest.FetchMetrics()
metrics.GetMetrics()
}