PKGBUILD/cmd/daemon/daemon.go

38 lines
734 B
Go
Raw Normal View History

package daemon
import (
"log"
2019-06-15 13:58:41 +00:00
"github.com/go-flucky/flucky/pkg/config"
"github.com/go-flucky/flucky/pkg/daemon"
"github.com/spf13/cobra"
)
var compression bool
var configFile string
var daemonCmd = &cobra.Command{
Use: "daemon",
Short: "Read continuously data from all enabled sensors",
Run: func(cmd *cobra.Command, args []string) {
2019-06-15 12:25:45 +00:00
// read configuration
cnf, err := config.Read(configFile)
if err != nil {
log.Fatalln(err)
}
err = daemon.Start(cnf, compression)
if err != nil {
panic(err)
}
},
}
func InitCmd(cmd *cobra.Command, cnfFile string) {
configFile = cnfFile
cmd.AddCommand(daemonCmd)
daemonCmd.Flags().BoolVarP(&compression, "compression", "c", true, "Compress measured values")
}