package main import ( "context" "database/sql" "fmt" "github.com/abelith/spellbook/internal/adapters/caster" "github.com/abelith/spellbook/internal/adapters/sqlite" "github.com/abelith/spellbook/internal/application" "github.com/abelith/spellbook/internal/cli" _ "modernc.org/sqlite" "os" "os/signal" "syscall" ) func handleErr(err error) { if err != nil { _, _ = fmt.Fprintln(os.Stderr, err) os.Exit(1) } } func main() { ctx, cancel := signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM) defer cancel() db, err := sql.Open("sqlite", "db.sql") handleErr(err) repo := sqlite.NewRepo(db) handleErr(repo.Init(ctx)) app := application.NewApplication(&caster.SpellCaster{}, repo, repo) root := cli.NewRootCmd(app) root.AddCommand( cli.NewAddCommand(app), cli.NewRmCommand(app), ) handleErr(root.Execute()) }