This repository was archived by the owner on Sep 11, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathmain.go
More file actions
74 lines (57 loc) · 1.3 KB
/
main.go
File metadata and controls
74 lines (57 loc) · 1.3 KB
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
69
70
71
72
73
74
package main
import (
"chobb/helpers"
"chobb/modules"
"flag"
"fmt"
"log"
"os"
"path"
"github.com/fatih/color"
)
func main() {
Command := flag.NewFlagSet(flag.Arg(0), flag.ExitOnError)
Cache := Command.Bool("enableCache", false, "Enables the cache")
CacheDisabled := Command.Bool("disableCache", false, "Disables the cache")
flag.Parse()
Arg := flag.Arg(0)
if Arg != "" {
Command.Parse(os.Args[2:])
}
if *CacheDisabled {
modules.RemoveCache()
}
if Arg == "check" {
if !modules.IsUpdated() {
helpers.BgInfoMessage("There is a new version for chob! To download it use chob update")
} else {
helpers.BgSuccessMessage("Yay! You are using the latest version!")
}
return
}
if Arg == "update" {
modules.UpdateChob()
return
}
if Arg == "" {
fmt.Println(color.RedString("I need a package name!"))
return
}
LogInit()
go modules.FetchApplications(Arg, Cache)
modules.CombineResults(Arg)
modules.SearchForApplication(Arg)
}
func LogInit() {
var LogFile string = path.Join(helpers.ChobPath(), "chob.log")
_, err := os.ReadDir(helpers.ChobPath())
if err != nil {
os.Mkdir(helpers.ChobPath(), 0777)
}
f, err := os.OpenFile(LogFile, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0666)
if err != nil {
log.Fatalf("error opening file: %v", err)
}
defer f.Close()
log.SetOutput(f)
}