-
Notifications
You must be signed in to change notification settings - Fork 0
/
projectmain.go
58 lines (45 loc) · 1.28 KB
/
projectmain.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
package main
import (
"fmt"
"github.com/dotloadmovie/wikintersection/network"
"github.com/dotloadmovie/wikintersection/utils"
"github.com/dotloadmovie/wikintersection/view"
"os"
)
func main() {
argsWithoutProg := os.Args[1:]
fmt.Println(argsWithoutProg)
switchCommand := argsWithoutProg[0]
if switchCommand == "compare" {
getIntersection(argsWithoutProg[1], argsWithoutProg[2], map[string]string {
"format": "json",
"formatversion": "2",
"action": "query",
"prop": "links",
"pllimit": "200",
})
}
if switchCommand == "search" {
getSearch(argsWithoutProg[1], map[string]string {
"action": "query",
"srlimit": "300",
"list": "search",
"&utf8":"",
"format":"json",
})
}
}
// getIntersection: get the intersection of two articles from Wikipedia
func getIntersection(first string, second string, params map[string]string) {
network.InitWiki(params)
firstResults := network.GetWiki(first)
secondResults := network.GetWiki(second)
intersection := utils.GetIntersect(firstResults, secondResults)
view.RenderTable(intersection)
}
// getSearch: get a list of article matches from Wikipedia
func getSearch(searchString string, params map[string]string) {
network.InitSearch(params)
results := network.GetSearch(searchString)
view.RenderTable(results)
}