37 lines
709 B
Go
37 lines
709 B
Go
package cmd
|
|
|
|
import (
|
|
"git.maurice.fr/thomas/mailout/pkg/config"
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
var (
|
|
configFile string
|
|
cfg *config.Config
|
|
)
|
|
|
|
var RootCmd = &cobra.Command{
|
|
Use: "mailoutctl",
|
|
Short: "mailout management utility",
|
|
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
|
|
var err error
|
|
cfg, err = config.LoadConfig(configFile)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
return nil
|
|
},
|
|
}
|
|
|
|
func InitRootCmd() {
|
|
InitUserCmd()
|
|
InitDKIMKeyCmd()
|
|
|
|
RootCmd.AddCommand(VersionCmd)
|
|
RootCmd.AddCommand(InitDBCmd)
|
|
RootCmd.AddCommand(UserCmd)
|
|
RootCmd.AddCommand(DKIMKeyCmd)
|
|
|
|
RootCmd.PersistentFlags().StringVarP(&configFile, "config", "c", "mailout.yml", "Configuration file")
|
|
}
|