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