chore
- minor refactor
This commit is contained in:
1 parent
7f85815839
commit
281d7d76d4
5 files changed
+38
-15
No files matched your search
@@ -0,0 +1,35 @@
|
||||
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()
|
||||
}
|
||||
Reference in new issue
Block a user