mailout/pkg/cmd/root.go
Thomas Maurice 09d3149932
All checks were successful
build / build (push) Successful in 1m10s
Build and release / build (push) Successful in 14m51s
feat(mail): adds a test subcomand
2024-02-13 18:30:54 +01:00

47 lines
882 B
Go

package cmd
import (
"os"
"path"
"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.AddCommand(TestCmd)
homeDir, err := os.UserHomeDir()
if err != nil {
panic(err)
}
defaultConfigFile := path.Join(homeDir, ".mailout.yml")
RootCmd.PersistentFlags().StringVarP(&configFile, "config", "c", defaultConfigFile, "Configuration file")
}