blob: 42eebdbde581a8c409d6a8378c6959ff5cec2906 [file] [log] [blame]
avm9996388e622d2021-01-22 18:57:58 +01001package main
2
3import (
4 "github.com/sirupsen/logrus"
5 "github.com/spf13/cobra"
6)
7
8var 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.
12Basically, it converts motion trigger emails notifications received into a state
13published in a MQTT topic.`,
14 Run: nil,
15}
16
17var (
18 verbose bool
19)
20
21func 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}