forked from TimothyYe/ydict
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
45 lines (38 loc) · 751 Bytes
/
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
package main
import (
"os"
"strings"
)
var (
proxy string
)
func main() {
//Check & load .env file
loadEnv()
if len(os.Args) == 1 {
displayUsage()
os.Exit(0)
}
if len(os.Args) == 2 && os.Args[1] == "-h" {
displayUsage()
os.Exit(0)
}
words, withVoice, withMore, isQuiet, withCache, clearCache := parseArgs(os.Args[1:])
if clearCache {
ClearCahceFiles()
return
}
queryP := queryParam{}
queryP.Words = words
queryP.WordString = strings.Join(words, " ")
queryP.WithMore = withMore
queryP.WithCache = withCache
queryP.IsQuiet = isQuiet
queryP.IsMulti = (len(words) > 1)
queryP.IsChinese = isChinese(queryP.WordString)
queryP.WithVoice = withVoice
if !isAvailableOS() {
queryP.WithVoice = 0
}
queryP.DoQuery()
}