feat: export command

This commit is contained in:
abelith committed 2026-08-16 22:39:51 +05:00
1 parent 92cb9267fc
commit f97e9b0aa9
3 files changed
+78

No files matched your search

+23
View File
@@ -2,7 +2,9 @@ package application
import (
"context"
"github.com/abelith/spellbook/internal/adapters/exporter"
"github.com/abelith/spellbook/internal/models"
"io"
)
type SpellCaster interface {
@@ -70,3 +72,24 @@ func (a *Application) CastSpell(
) (models.CastResult, error) {
return a.caster.Cast(ctx, spellCast)
}
func (a *Application) ExportSpells(
ctx context.Context,
name string,
w io.Writer,
) error {
ch, errCh, err := a.spellQuery.Export(ctx)
if err != nil {
return err
}
if err := exporter.Export(ctx, name, ch, w); err != nil {
return err
}
if err := <-errCh; err != nil {
return err
}
return nil
}