-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdrive-tree.go
68 lines (49 loc) · 1.07 KB
/
drive-tree.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
62
63
64
65
66
67
68
package main
import (
"drive-tree/internal/authentication"
"drive-tree/internal/datamng"
"drive-tree/internal/tree"
"drive-tree/internal/web"
"flag"
"fmt"
"log"
)
func main() {
flag.Usage = usage
flag.Parse()
args := flag.Args()
if len(args) < 1 {
usage()
return
}
if args[0] == "scraper" {
scraper()
} else if args[0] == "web" {
viewer()
} else {
usage()
}
}
func usage() {
fmt.Println("Usage:")
fmt.Println("\tdrive-tree scraper --> parse all your files")
fmt.Println("\tdrive-tree web --> view your files on web after scraper")
}
func scraper() {
srv := authentication.Authentication()
//startNodeId := "1NesnNegi27dNuYL2E92oWav0ZShCIimo"
myDriveStructure := tree.Run(srv)
err := datamng.SaveData(myDriveStructure)
if err != nil {
return
}
log.Println("\n\n\nAll files were successfully parsed...")
log.Println("}Use 'drive-tree web' to view your folder size on web")
}
func viewer() {
myDriveStructure, startNodeId := datamng.LoadData()
if myDriveStructure != nil {
// Create web server
web.Run(myDriveStructure, startNodeId)
}
}