PKGBUILD/cmd/temperature/get.go

35 lines
772 B
Go
Raw Normal View History

package temperature
2018-11-19 21:36:21 +00:00
import (
"log"
"os"
"git.cryptic.systems/fh-trier/go-flucky/pkg/temperature"
"github.com/spf13/cobra"
)
2018-11-29 19:03:42 +00:00
var follow, push bool
2018-11-19 21:36:21 +00:00
var getTemperatureCmd = &cobra.Command{
Use: "get",
Short: "get temperature from sensor",
Run: func(cmd *cobra.Command, args []string) {
2018-11-28 17:07:20 +00:00
if follow {
2018-11-29 19:03:42 +00:00
if err := temperature.Follow(args, push, configDir, os.Stdout); err != nil {
2018-11-28 17:07:20 +00:00
log.Fatal(err)
}
} else {
2018-11-29 19:03:42 +00:00
if err := temperature.Get(args, push, configDir, os.Stdout); err != nil {
2018-11-28 17:07:20 +00:00
log.Fatal(err)
}
2018-11-19 21:36:21 +00:00
}
},
}
func init() {
temperatureCmd.AddCommand(getTemperatureCmd)
2018-11-28 17:07:20 +00:00
getTemperatureCmd.Flags().BoolVarP(&follow, "follow", "f", false, "Follow output")
getTemperatureCmd.Flags().BoolVarP(&push, "push", "p", false, "Push to remote server")
2018-11-19 21:36:21 +00:00
}