51 lines
976 B
Go
51 lines
976 B
Go
package cmd
|
|
|
|
import (
|
|
// "reichard.io/imagini/routes"
|
|
"reichard.io/imagini/internal/db"
|
|
"reichard.io/imagini/internal/config"
|
|
|
|
"github.com/urfave/cli/v2"
|
|
// "net/http"
|
|
// "log"
|
|
"fmt"
|
|
)
|
|
|
|
var CmdServe = cli.Command{
|
|
Name: "serve",
|
|
Aliases: []string{"s"},
|
|
Usage: "Start Imagini web server.",
|
|
Action: serveWeb,
|
|
}
|
|
|
|
var CmdDBTest = cli.Command{
|
|
Name: "db",
|
|
Aliases: []string{"d"},
|
|
Usage: "test db.",
|
|
Action: testDatabase,
|
|
}
|
|
|
|
func serveWeb(ctx *cli.Context) error {
|
|
c := config.NewConfig()
|
|
db.ConnectDB(c)
|
|
//db.PopulateTestData()
|
|
newItems := db.ItemsFromAlbum(1, 2)
|
|
|
|
fmt.Printf("%+v\n", newItems)
|
|
return nil
|
|
|
|
|
|
// routes.RegisterRoutes()
|
|
|
|
// if err := http.ListenAndServe(":8080", nil); err != nil {
|
|
// log.Fatal(err)
|
|
// }
|
|
// return nil
|
|
}
|
|
|
|
func testDatabase(ctx *cli.Context) error {
|
|
resp := db.ItemsFromAlbum(1, 3)
|
|
fmt.Printf("%v", resp)
|
|
return nil
|
|
}
|