- command handlers
This commit is contained in:
abelith committed 2026-08-04 01:00:00 +05:00
1 parent 3673d318a1
commit 213562956c
6 files changed
+249 -1

No files matched your search

+29
View File
@@ -0,0 +1,29 @@
package cli
import (
"github.com/spf13/cobra"
"spellbook/internal/models"
"strings"
)
func NewAddCommand(app Application) *cobra.Command {
spell := models.Spell{}
cmd := &cobra.Command{
Use: "add [flags] -- [spell]",
Short: "Add new spell",
Long: `WIP`,
RunE: func(cmd *cobra.Command, args []string) error {
ctx := cmd.Context()
spell.Spell = strings.Join(args, " ")
return app.AddSpell(ctx, spell)
},
}
cmd.Flags().StringVarP(&spell.Name, "name", "n", "", "Spell name")
cmd.Flags().StringSliceVarP(&spell.Tags, "tags", "t", nil, "Spell tags")
cmd.Flags().StringVarP(&spell.ShortDesc, "desc", "d", "", "Short spell description")
return cmd
}