blasphem/internal/common/common.go
2022-11-13 11:55:10 -05:00

34 lines
638 B
Go

// common contains common functionality for blasphem.
package common
import (
"github.com/spf13/cobra"
)
const (
// AppName is the name of the application.
AppName = "blasphem"
)
type cmdOptions interface {
Options(*cobra.Command, []string) error
Execute() error
}
// RunE is a convenience function for use with cobra.
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
}
}