32 lines
486 B
Go
32 lines
486 B
Go
|
package common
|
||
|
|
||
|
import (
|
||
|
"github.com/spf13/cobra"
|
||
|
)
|
||
|
|
||
|
const (
|
||
|
AppName = "blasphem"
|
||
|
)
|
||
|
|
||
|
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
|
||
|
}
|
||
|
}
|