github.com/JarrahG/buffalocli@v0.0.0-20230801092127-b85bfd5d395a/internal/cmd/destroy/action.go (about) 1 package destroy 2 3 import ( 4 "fmt" 5 6 "github.com/gobuffalo/flect" 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: "Destroy action files", 16 RunE: func(cmd *cobra.Command, args []string) error { 17 if len(args) == 0 { 18 return fmt.Errorf("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 := flect.Underscore(name) 25 return removeActions(fileName) 26 }, 27 }