Files
spellbook/internal/controllers/cli/cli.go
T
abelith 4447b7343f feat: search cmd
chore: raw sql replaced with squirrel
fix: -n is now required for add cmd
2026-08-15 18:38:26 +05:00

37 lines
809 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(ver string, app Application) *CLI {
root := NewRootCmd(ver, app)
root.AddCommand(
NewAddCommand(app),
NewRmCommand(app),
NewSearchCmd(app),
)
return &CLI{
root: root,
}
}
func (c *CLI) Run(_ context.Context) error {
return c.root.Execute()
}