github.com/jacobsoderblom/buffalo@v0.11.0/buffalo/cmd/destroy/action.go (about) 1 package destroy 2 3 import ( 4 "errors" 5 6 "github.com/markbates/inflect" 7 "github.com/spf13/cobra" 8 ) 9 10 //ActionCmd destroys passed action file 11 var ActionCmd = &cobra.Command{ 12 Use: "action [name]", 13 //Example: "resource cars", 14 Aliases: []string{"a"}, 15 Short: "Destroys action 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 action file name in order to destroy it") 19 } 20 21 name := args[0] 22 23 //Generated actions keep the same name (not plural). 24 fileName := inflect.Underscore(name) 25 26 removeActions(fileName) 27 return nil 28 }, 29 }