owl-blogs/cmd/owl/main.go

54 lines
1.2 KiB
Go
Raw Permalink Normal View History

2023-06-25 18:04:06 +00:00
package main
import (
2023-07-08 12:28:15 +00:00
"fmt"
"os"
2023-06-25 19:32:36 +00:00
"owl-blogs/app"
2023-07-16 19:48:39 +00:00
entrytypes "owl-blogs/entry_types"
2023-06-25 19:32:36 +00:00
"owl-blogs/infra"
"owl-blogs/web"
2023-07-08 12:28:15 +00:00
"github.com/spf13/cobra"
2023-06-25 18:04:06 +00:00
)
2023-07-07 19:04:25 +00:00
const DbPath = "owlblogs.db"
2023-07-08 12:28:15 +00:00
var rootCmd = &cobra.Command{
Use: "owl",
Short: "Owl Blogs is a not so static blog generator",
}
func Execute() {
if err := rootCmd.Execute(); err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
}
2023-07-07 19:04:25 +00:00
func App(db infra.Database) *web.WebApp {
2023-07-08 11:28:06 +00:00
registry := app.NewEntryTypeRegistry()
2023-07-16 19:48:39 +00:00
registry.Register(&entrytypes.Image{})
registry.Register(&entrytypes.Article{})
registry.Register(&entrytypes.Page{})
registry.Register(&entrytypes.Recipe{})
registry.Register(&entrytypes.Note{})
2023-07-18 19:03:33 +00:00
registry.Register(&entrytypes.Bookmark{})
registry.Register(&entrytypes.Reply{})
2023-07-06 17:42:54 +00:00
2023-07-08 09:08:55 +00:00
entryRepo := infra.NewEntryRepository(db, registry)
binRepo := infra.NewBinaryFileRepo(db)
2023-07-08 11:28:06 +00:00
authorRepo := infra.NewDefaultAuthorRepo(db)
siteConfigRepo := infra.NewConfigRepo(db)
2023-07-08 09:08:55 +00:00
entryService := app.NewEntryService(entryRepo)
binaryService := app.NewBinaryFileService(binRepo)
2023-07-16 19:48:39 +00:00
authorService := app.NewAuthorService(authorRepo, siteConfigRepo)
2023-07-08 11:28:06 +00:00
2023-07-17 18:44:59 +00:00
return web.NewWebApp(entryService, registry, binaryService, authorService, siteConfigRepo)
2023-07-06 20:16:52 +00:00
}
func main() {
2023-07-08 12:28:15 +00:00
Execute()
2023-06-25 18:04:06 +00:00
}