| package main |
| |
| import ( |
| "github.com/sirupsen/logrus" |
| "github.com/spf13/cobra" |
| ) |
| |
| var rootCmd = &cobra.Command{ |
| Use: "hichipbridge", |
| Short: "hichip2mqtt bridge daemon", |
| Long: `Daemon which serves as a bridge for hichip IP cameras and MQTT. |
| Basically, it converts motion trigger emails notifications received into a state |
| published in a MQTT topic.`, |
| Run: nil, |
| } |
| |
| var ( |
| verbose bool |
| ) |
| |
| func init() { |
| cobra.OnInitialize() |
| rootCmd.PersistentFlags().BoolVarP(&verbose, "verbose", "v", false, |
| "print out more debug information") |
| rootCmd.PersistentPreRun = func(cmd *cobra.Command, args []string) { |
| if verbose { |
| logrus.SetLevel(logrus.DebugLevel) |
| } else { |
| logrus.SetLevel(logrus.InfoLevel) |
| } |
| } |
| } |