2021-01-03 03:21:11 +00:00
|
|
|
package cmd
|
|
|
|
|
|
|
|
import (
|
2021-01-08 02:45:59 +00:00
|
|
|
// "reichard.io/imagini/routes"
|
2021-01-06 19:36:09 +00:00
|
|
|
"reichard.io/imagini/internal/db"
|
2021-01-08 02:45:59 +00:00
|
|
|
"reichard.io/imagini/internal/config"
|
2021-01-04 05:16:58 +00:00
|
|
|
|
2021-01-03 22:31:16 +00:00
|
|
|
"github.com/urfave/cli/v2"
|
2021-01-08 02:45:59 +00:00
|
|
|
// "net/http"
|
|
|
|
// "log"
|
2021-01-04 05:16:58 +00:00
|
|
|
"fmt"
|
2021-01-03 03:21:11 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
var CmdServe = cli.Command{
|
2021-01-03 22:31:16 +00:00
|
|
|
Name: "serve",
|
|
|
|
Aliases: []string{"s"},
|
|
|
|
Usage: "Start Imagini web server.",
|
|
|
|
Action: serveWeb,
|
2021-01-03 03:21:11 +00:00
|
|
|
}
|
|
|
|
|
2021-01-04 05:16:58 +00:00
|
|
|
var CmdDBTest = cli.Command{
|
|
|
|
Name: "db",
|
|
|
|
Aliases: []string{"d"},
|
|
|
|
Usage: "test db.",
|
|
|
|
Action: testDatabase,
|
|
|
|
}
|
|
|
|
|
2021-01-03 03:21:11 +00:00
|
|
|
func serveWeb(ctx *cli.Context) error {
|
2021-01-08 02:45:59 +00:00
|
|
|
c := config.NewConfig()
|
|
|
|
db.ConnectDB(c)
|
|
|
|
//db.PopulateTestData()
|
|
|
|
newItems := db.ItemsFromAlbum(1, 2)
|
2021-01-03 22:31:16 +00:00
|
|
|
|
2021-01-08 02:45:59 +00:00
|
|
|
fmt.Printf("%+v\n", newItems)
|
2021-01-03 03:21:11 +00:00
|
|
|
return nil
|
2021-01-08 02:45:59 +00:00
|
|
|
|
|
|
|
|
|
|
|
// routes.RegisterRoutes()
|
|
|
|
|
|
|
|
// if err := http.ListenAndServe(":8080", nil); err != nil {
|
|
|
|
// log.Fatal(err)
|
|
|
|
// }
|
|
|
|
// return nil
|
2021-01-03 03:21:11 +00:00
|
|
|
}
|
2021-01-04 05:16:58 +00:00
|
|
|
|
|
|
|
func testDatabase(ctx *cli.Context) error {
|
|
|
|
resp := db.ItemsFromAlbum(1, 3)
|
|
|
|
fmt.Printf("%v", resp)
|
|
|
|
return nil
|
|
|
|
}
|