feat: import interface

This commit is contained in:
abelith committed 2026-08-21 15:27:37 +05:00
1 parent f97e9b0aa9
commit 69af7eaee3
3 files changed
+66

No files matched your search

+22
View File
@@ -3,6 +3,7 @@ package application
import (
"context"
"github.com/abelith/spellbook/internal/adapters/exporter"
"github.com/abelith/spellbook/internal/adapters/importer"
"github.com/abelith/spellbook/internal/models"
"io"
)
@@ -93,3 +94,24 @@ func (a *Application) ExportSpells(
return nil
}
func (a *Application) ImportSpells(
ctx context.Context,
name string,
r io.Reader,
) error {
ch, errCh, err := importer.Import(ctx, name, r)
if err != nil {
return err
}
if err := a.spellCmd.Import(ctx, ch); err != nil {
return err
}
if err := <-errCh; err != nil {
return err
}
return nil
}