This commit is contained in:
@@ -2,14 +2,18 @@ package cmd
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
"kontor-api-gin/internal/models"
|
"kontor-api-gin/internal/models"
|
||||||
"log/slog"
|
"log/slog"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
"github.com/spf13/viper"
|
||||||
"resty.dev/v3"
|
"resty.dev/v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var server string
|
||||||
|
|
||||||
var exportCmd = &cobra.Command{
|
var exportCmd = &cobra.Command{
|
||||||
Use: "export",
|
Use: "export",
|
||||||
Short: "Export Kontor Database",
|
Short: "Export Kontor Database",
|
||||||
@@ -18,6 +22,7 @@ var exportCmd = &cobra.Command{
|
|||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
slog.Info("export kontor")
|
slog.Info("export kontor")
|
||||||
slog.Info("Verbosity level", "level", verbose)
|
slog.Info("Verbosity level", "level", verbose)
|
||||||
|
slog.Info(fmt.Sprintf("Using server: %s", server))
|
||||||
var login LoginResponse
|
var login LoginResponse
|
||||||
|
|
||||||
client := resty.New()
|
client := resty.New()
|
||||||
@@ -87,6 +92,7 @@ var exportCmd = &cobra.Command{
|
|||||||
book_authors []models.BookAuthorDTO
|
book_authors []models.BookAuthorDTO
|
||||||
mediaarticles []models.MediaArticleDTO
|
mediaarticles []models.MediaArticleDTO
|
||||||
mediavideos []models.MediaVideoDTO
|
mediavideos []models.MediaVideoDTO
|
||||||
|
mediaactors []models.MediaActorDTO
|
||||||
mediafiles []models.MediaFileDTO
|
mediafiles []models.MediaFileDTO
|
||||||
medialofis []models.MediaLoFiDTO
|
medialofis []models.MediaLoFiDTO
|
||||||
profiles []models.ProfileDTO
|
profiles []models.ProfileDTO
|
||||||
@@ -122,6 +128,7 @@ var exportCmd = &cobra.Command{
|
|||||||
"http://127.0.0.1:8550/api/v1/bookshelf/bookauthors": &book_authors,
|
"http://127.0.0.1:8550/api/v1/bookshelf/bookauthors": &book_authors,
|
||||||
"http://127.0.0.1:8550/api/v1/media/articles": &mediaarticles,
|
"http://127.0.0.1:8550/api/v1/media/articles": &mediaarticles,
|
||||||
"http://127.0.0.1:8550/api/v1/media/videos": &mediavideos,
|
"http://127.0.0.1:8550/api/v1/media/videos": &mediavideos,
|
||||||
|
"http://127.0.0.1:8550/api/v1/media/actors": &mediaactors,
|
||||||
"http://127.0.0.1:8550/api/v1/media/files": &mediafiles,
|
"http://127.0.0.1:8550/api/v1/media/files": &mediafiles,
|
||||||
"http://127.0.0.1:8550/api/v1/media/lofis": &medialofis,
|
"http://127.0.0.1:8550/api/v1/media/lofis": &medialofis,
|
||||||
"http://127.0.0.1:8550/api/v1/user/profiles": &profiles,
|
"http://127.0.0.1:8550/api/v1/user/profiles": &profiles,
|
||||||
@@ -159,6 +166,7 @@ var exportCmd = &cobra.Command{
|
|||||||
BookAuthor: book_authors,
|
BookAuthor: book_authors,
|
||||||
MediaArticle: mediaarticles,
|
MediaArticle: mediaarticles,
|
||||||
MediaVideo: mediavideos,
|
MediaVideo: mediavideos,
|
||||||
|
MediaActor: mediaactors,
|
||||||
MediaFile: mediafiles,
|
MediaFile: mediafiles,
|
||||||
MediaLoFi: medialofis,
|
MediaLoFi: medialofis,
|
||||||
Profile: profiles,
|
Profile: profiles,
|
||||||
@@ -208,4 +216,7 @@ func PostJSON(client *resty.Client, url string, v any) {
|
|||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
rootCmd.AddCommand(exportCmd)
|
rootCmd.AddCommand(exportCmd)
|
||||||
|
|
||||||
|
exportCmd.PersistentFlags().StringVarP(&server, "server", "s", "http://127.0.0.1:8550", "Define server to get Kontor items")
|
||||||
|
viper.BindPFlag("server", exportCmd.PersistentFlags().Lookup("server"))
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user