package sensor import ( "log" "os" "git.cryptic.systems/fh-trier/go-flucky/pkg/cli" "git.cryptic.systems/fh-trier/go-flucky/pkg/config" "github.com/spf13/cobra" ) var listSensorCmd = &cobra.Command{ Use: "ls", Short: "List Sensors", Aliases: []string{"list"}, 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) }