package cmd import ( "fmt" "kontor-api-gin/internal/api" "kontor-api-gin/internal/config" "log/slog" "github.com/spf13/cobra" "resty.dev/v3" ) var exportCmd = &cobra.Command{ Use: "export", Short: "Export Kontor Database", Long: "Export Kontor Database to given file", // Args: cobra.ExactArgs(1), Run: func(cmd *cobra.Command, args []string) { slog.Info("export kontor") slog.Info("Verbosity level", "level", config.Verbose) slog.Info(fmt.Sprintf("Using server: %s", config.ServerName)) client := resty.New() defer client.Close() localServer := config.Config.Server[config.ServerName] export, _ := api.GetData(localServer, config.Config.ApiVersion) err := api.WriteJson(export, config.FileName) if err != nil { slog.Info("WriteJon failed", "Error:", err) } slog.Info("export kontor finished") }, } func init() { rootCmd.AddCommand(exportCmd) }