Files
spellbook/internal/controllers/cli/cli.go
T
abelith 281d7d76d4 chore
- minor refactor
2026-08-08 17:18:34 +05:00

36 lines
771 B
Go

package cli
import (
"context"
"github.com/abelith/spellbook/internal/models"
"github.com/spf13/cobra"
)
type Application interface {
AddSpell(ctx context.Context, spell models.Spell) error
GetSpell(ctx context.Context, spellName string) (models.Spell, error)
GetSpells(ctx context.Context, query models.SearchQuery) ([]models.Spell, error)
DeleteSpell(ctx context.Context, spellName string) error
CastSpell(ctx context.Context, spellCast models.SpellCast) (models.CastResult, error)
}
type CLI struct {
root *cobra.Command
}
func NewCLI(app Application) *CLI {
root := NewRootCmd(app)
root.AddCommand(
NewAddCommand(app),
NewRmCommand(app),
)
return &CLI{
root: root,
}
}
func (c *CLI) Run(_ context.Context) error {
return c.root.Execute()
}