Redmage/main.go
2024-04-12 01:32:06 +07:00

38 lines
655 B
Go

package main
import (
"context"
"embed"
"errors"
"io/fs"
"os"
"os/signal"
"github.com/joho/godotenv"
"github.com/tigorlazuardi/redmage/cli"
"github.com/tigorlazuardi/redmage/db"
)
//go:embed db/migrations/*.sql
var Migrations embed.FS
//go:embed public/*
var PublicFS embed.FS
func main() {
_ = godotenv.Load()
db.Migrations = Migrations
var err error
cli.PublicDir, err = fs.Sub(PublicFS, "public")
if err != nil {
panic(errors.New("failed to create sub filesystem"))
}
ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt)
defer stop()
if err := cli.RootCmd.ExecuteContext(ctx); err != nil {
os.Exit(1)
}
}