-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.go
54 lines (43 loc) · 1.05 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
package main
import (
"flag"
"fmt"
surveyCore "github.com/AlecAivazis/survey/v2/core"
"github.com/PierreKieffer/http-tanker/pkg/cli"
"github.com/PierreKieffer/http-tanker/pkg/color"
"github.com/PierreKieffer/http-tanker/pkg/core"
"github.com/mgutz/ansi"
"os/user"
)
func init() {
//Override survey colors
surveyCore.TemplateFuncsWithColor["color"] = func(style string) string {
switch style {
case "white":
if color.Is256ColorSupported() {
return fmt.Sprintf("\x1b[%d;5;%dm", 38, 242)
} else {
return ansi.ColorCode("default")
}
default:
return ansi.ColorCode(style)
}
}
}
func main() {
localUser, err := user.Current()
databaseDir := flag.String("db", fmt.Sprintf("%v/http-tanker", localUser.HomeDir), "tanker database directory")
database := &core.Database{
DatabaseDir: *databaseDir,
DatabaseFile: fmt.Sprintf("%s/http-tanker-data.json", *databaseDir),
}
err = database.InitDB()
if err != nil {
fmt.Println(err)
}
app := &cli.App{
SigChan: make(chan cli.Signal),
Database: database,
}
app.Run()
}