ente/main.go

46 lines
877 B
Go
Raw Normal View History

package main
2023-09-13 08:51:05 +00:00
import (
"cli-go/cmd"
2023-10-18 12:22:41 +00:00
"cli-go/internal"
2023-09-13 08:51:05 +00:00
"cli-go/internal/api"
"cli-go/pkg"
2023-09-23 10:45:10 +00:00
"cli-go/pkg/secrets"
2023-10-18 12:22:41 +00:00
"cli-go/utils/constants"
"fmt"
"log"
2023-09-13 08:51:05 +00:00
)
func main() {
2023-10-18 12:22:41 +00:00
cliDBPath := ""
if secrets.IsRunningInContainer() {
cliDBPath = constants.CliDataPath
_, err := internal.ValidateDirForWrite(cliDBPath)
if err != nil {
log.Fatalf("Please mount a volume to %s to persist cli data\n%v\n", cliDBPath, err)
}
}
db, err := pkg.GetDB(fmt.Sprintf("%sente-cli.db", cliDBPath))
2023-09-13 08:51:05 +00:00
if err != nil {
panic(err)
}
ctrl := pkg.ClICtrl{
2023-09-15 10:55:29 +00:00
Client: api.NewClient(api.Params{
Debug: false,
2023-09-25 08:33:58 +00:00
//Host: "http://localhost:8080",
2023-09-15 10:55:29 +00:00
}),
2023-09-22 16:15:01 +00:00
DB: db,
2023-09-27 08:39:44 +00:00
KeyHolder: secrets.NewKeyHolder(secrets.GetOrCreateClISecret()),
2023-09-15 10:55:29 +00:00
}
err = ctrl.Init()
if err != nil {
panic(err)
2023-09-13 08:51:05 +00:00
}
defer func() {
if err := db.Close(); err != nil {
panic(err)
}
}()
cmd.Execute(&ctrl)
}