root.go 712 B

12345678910111213141516171819202122232425262728293031
  1. package main
  2. import (
  3. "github.com/sirupsen/logrus"
  4. "github.com/spf13/cobra"
  5. )
  6. var rootCmd = &cobra.Command{
  7. Use: "guerrillad",
  8. Short: "small SMTP daemon",
  9. Long: `It's a small SMTP daemon written in Go, for the purpose of receiving large volumes of email.
  10. Written for GuerrillaMail.com which processes tens of thousands of emails every hour.`,
  11. Run: nil,
  12. }
  13. var (
  14. verbose bool
  15. )
  16. func init() {
  17. cobra.OnInitialize()
  18. rootCmd.PersistentFlags().BoolVarP(&verbose, "verbose", "v", false,
  19. "print out more debug information")
  20. rootCmd.PersistentPreRun = func(cmd *cobra.Command, args []string) {
  21. if verbose {
  22. logrus.SetLevel(logrus.DebugLevel)
  23. } else {
  24. logrus.SetLevel(logrus.InfoLevel)
  25. }
  26. }
  27. }