feat: export command
This commit is contained in:
1 parent
92cb9267fc
commit
f97e9b0aa9
3 files changed
+78
No files matched your search
@@ -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
|
||||
}
|
||||
Reference in new issue
Block a user