avm99963 | 88e622d | 2021-01-22 18:57:58 +0100 | [diff] [blame] | 1 | package main |
| 2 | |
| 3 | import ( |
| 4 | "github.com/sirupsen/logrus" |
| 5 | "github.com/spf13/cobra" |
| 6 | ) |
| 7 | |
| 8 | var rootCmd = &cobra.Command{ |
| 9 | Use: "hichipbridge", |
| 10 | Short: "hichip2mqtt bridge daemon", |
| 11 | Long: `Daemon which serves as a bridge for hichip IP cameras and MQTT. |
| 12 | Basically, it converts motion trigger emails notifications received into a state |
| 13 | published in a MQTT topic.`, |
| 14 | Run: nil, |
| 15 | } |
| 16 | |
| 17 | var ( |
| 18 | verbose bool |
| 19 | ) |
| 20 | |
| 21 | func init() { |
| 22 | cobra.OnInitialize() |
| 23 | rootCmd.PersistentFlags().BoolVarP(&verbose, "verbose", "v", false, |
| 24 | "print out more debug information") |
| 25 | rootCmd.PersistentPreRun = func(cmd *cobra.Command, args []string) { |
| 26 | if verbose { |
| 27 | logrus.SetLevel(logrus.DebugLevel) |
| 28 | } else { |
| 29 | logrus.SetLevel(logrus.InfoLevel) |
| 30 | } |
| 31 | } |
| 32 | } |