package sensor import ( "log" "os" "github.com/go-flucky/flucky/pkg/cli" "github.com/go-flucky/flucky/pkg/config" "github.com/spf13/cobra" ) var listSensorCmd = &cobra.Command{ Use: "list", Short: "List Sensors", Aliases: []string{"ls"}, Run: func(cmd *cobra.Command, args []string) { // read configuration cnf, err := config.Read(*configFile) if err != nil { log.Fatalln(err) } // print sensors on stdout err = cli.PrintSensors(cnf, os.Stdout) if err != nil { log.Fatalln(err) } // save new configuration err = config.Write(cnf, *configFile) if err != nil { log.Fatalln(err) } }, } func init() { sensorCmd.AddCommand(listSensorCmd) }