feat
- main chore - minor changes
This commit is contained in:
1 parent
213562956c
commit
e4737ca179
10 files changed
+89
-24
No files matched your search
+42
@@ -1 +1,43 @@
|
||||
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())
|
||||
}
|
||||
Reference in new issue
Block a user