-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
61 lines (54 loc) · 1.19 KB
/
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package main
import (
"fmt"
"os"
)
var (
gopath = os.Getenv("GOPATH")
)
func printHelp() {
fmt.Println("bAsk - bing chat for the CLI - version v0.2.1")
fmt.Println()
fmt.Println("Usage:")
fmt.Println("\tbask [args]")
fmt.Println()
fmt.Println("Arguments:")
fmt.Println("\t-q [query] -> sends your query and gets the response from the Bing chat AI")
fmt.Println("\t-c [cookie] -> sets your Bing cookie")
fmt.Println("\t-h -> displays this message")
os.Exit(0)
}
func main() {
args := os.Args[1:]
if len(args) == 0 {
printHelp()
}
switch args[0] {
case "-q":
if len(args) < 2 {
fmt.Println("bAsk - No query provided!")
} else {
if cookieExists() {
search(args[1])
} else {
fmt.Println("bAsk - No cookie set!")
fmt.Println("Please set your cookie using \"bask -c [cookie]\", then try again.")
}
}
case "-c":
if len(args) < 2 {
fmt.Println("bAsk - No cookie provided!")
} else {
if gopath != "" {
setCookie(args[1])
} else {
fmt.Println("bAsk - GOPATH environment variable is undefined!")
fmt.Println("Please verify your GOPATH environment variable is set properly.")
}
}
case "-h":
printHelp()
default:
printHelp()
}
}