github.com/cheikhshift/buffalo@v0.9.5/buffalo/cmd/destroy/action.go (about) 1 package destroy 2 3 import ( 4 "errors" 5 "os" 6 7 "github.com/markbates/inflect" 8 "github.com/spf13/cobra" 9 ) 10 11 //ActionCmd destroys passed action file 12 var ActionCmd = &cobra.Command{ 13 Use: "action [name]", 14 //Example: "resource cars", 15 Aliases: []string{"a"}, 16 Short: "Destroys action files.", 17 RunE: func(cmd *cobra.Command, args []string) error { 18 if _, err := os.Stat(".buffalo.dev.yml"); os.IsNotExist(err) { 19 return errors.New("destroy needs to run in your buffalo project root") 20 } 21 22 if len(args) == 0 { 23 return errors.New("you need to provide a valid action file name in order to destroy it") 24 } 25 26 name := args[0] 27 28 //Generated actions keep the same name (not plural). 29 fileName := inflect.Underscore(name) 30 31 removeActions(fileName) 32 return nil 33 }, 34 }