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