-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
51 lines (38 loc) · 1.17 KB
/
main.go
File metadata and controls
51 lines (38 loc) · 1.17 KB
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
package main
import (
"fmt"
)
var help = `
Usage:
infinit-task <repository> <revision>
- repository must contain the repository owner and name separated by a slash
- revison can be a branch or commit SHA
Example:
infinit-task lodash/lodash some-branch-name
infinit-task lodash/lodash (revision defaults to branch 'main')
infinit-task lodash/lodash c7c70a7da5172111b99bb45e45532ed034d7b5b9
`
func main() {
repo, err := getArgument(0)
if err != nil {
panic("Repository not provided, " + err.Error() + help)
}
revision, err := getArgument(1)
if err != nil {
revision = "main"
}
fmt.Println("Computing stats for repository:", repo, "at revision:", revision)
url := "https://api.github.com/repos/" + repo + "/zipball/" + revision
zipFileReader, err := NewZipFileReader(url)
if err != nil {
panic("Could not retrieve repository file reader" + err.Error())
}
repoFileContent, err := zipFileReader.GetFileContentByExtention([]string{".js", ".ts"})
if err != nil {
panic("Could not retrieve repository file content" + err.Error())
}
stats := NewCharFrequency(repoFileContent)
fmt.Println("Result:")
fmt.Println("======")
fmt.Println(stats.ToString())
}