root.go 703 B

12345678910111213141516171819202122232425262728293031
  1. package main
  2. import (
  3. log "github.com/Sirupsen/logrus"
  4. "github.com/spf13/cobra"
  5. )
  6. var rootCmd = &cobra.Command{
  7. Use: "guerrillad",
  8. Short: "small SMTP server",
  9. Long: `It's a small SMTP server written in Go, for the purpose of receiving large volume 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. log.SetLevel(log.DebugLevel)
  23. } else {
  24. log.SetLevel(log.InfoLevel)
  25. }
  26. }
  27. }