stillbox/internal/common/common.go

28 lines
453 B
Go
Raw Normal View History

2024-07-14 13:47:48 -04:00
package common
import (
"github.com/spf13/cobra"
)
type cmdOptions interface {
Options(*cobra.Command, []string) error
Execute() error
}
func RunE(c cmdOptions) func(cmd *cobra.Command, args []string) error {
return func(cmd *cobra.Command, args []string) error {
err := c.Options(cmd, args)
if err != nil {
cmd.SilenceUsage = true
return err
}
err = c.Execute()
if err != nil {
cmd.SilenceUsage = true
}
return err
}
}