-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
35 lines (30 loc) · 799 Bytes
/
main.go
File metadata and controls
35 lines (30 loc) · 799 Bytes
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
package main
import (
"flag"
"funnyJSON/JSONExplorer"
"log"
)
func main() {
// 命令行参数
var jsonFilePath, styleArg, iconFamily string
flag.StringVar(&jsonFilePath, "f", "", "path to the JSON file")
flag.StringVar(&styleArg, "s", "", "style for the JSON visualization(tree in default)")
flag.StringVar(&iconFamily, "i", "", "icon family for the JSON visualization(null in default)")
flag.Parse()
if jsonFilePath == "" {
log.Fatalf("Error: '-f' flag is required but not provided.")
}
var drawer JSONExplorer.Explorer
drawer = &JSONExplorer.Drawer{}
err := drawer.ParseJSON(jsonFilePath)
if err != nil {
log.Fatalf("ReadFile error: %v", err)
}
if iconFamily != "" {
drawer.InitIcon(iconFamily)
}
if styleArg != "" {
drawer.InitStyle(styleArg)
}
drawer.Show()
}