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,29 @@
|
||||
package cli
|
||||
|
||||
import (
|
||||
"github.com/abelith/spellbook/internal/models"
|
||||
"github.com/spf13/cobra"
|
||||
"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
|
||||
}
|
||||
Reference in new issue
Block a user