github.com/bscott/buffalo@v0.11.1/buffalo/cmd/destroy/model.go (about) 1 package destroy 2 3 import ( 4 "errors" 5 6 "github.com/markbates/inflect" 7 "github.com/spf13/cobra" 8 ) 9 10 //ModelCmd destroys a passed model 11 var ModelCmd = &cobra.Command{ 12 Use: "model [name]", 13 //Example: "resource cars", 14 Aliases: []string{"m"}, 15 Short: "Destroys model files.", 16 RunE: func(cmd *cobra.Command, args []string) error { 17 if len(args) == 0 { 18 return errors.New("you need to provide a valid model name in order to destroy it") 19 } 20 21 name := args[0] 22 fileName := inflect.Pluralize(inflect.Underscore(name)) 23 24 removeModel(name) 25 removeMigrations(fileName) 26 27 return nil 28 }, 29 }