2019-06-16 18:11:10 +00:00
|
|
|
package rgbled
|
|
|
|
|
|
|
|
import (
|
|
|
|
"log"
|
|
|
|
|
|
|
|
"github.com/go-flucky/flucky/pkg/config"
|
|
|
|
"github.com/go-flucky/flucky/pkg/rgbled"
|
|
|
|
"github.com/spf13/cobra"
|
|
|
|
)
|
|
|
|
|
|
|
|
var offRgbLedCmd = &cobra.Command{
|
|
|
|
Use: "off",
|
|
|
|
Short: "Turn a RGB-LED color off",
|
|
|
|
Example: `flucky rgb-led off <name/uuid> <blue>
|
|
|
|
flucky rgb-led off my-led`,
|
|
|
|
Run: func(cmd *cobra.Command, args []string) {
|
|
|
|
|
|
|
|
// read configuration
|
2019-08-19 10:24:08 +00:00
|
|
|
cnf, err := config.Read(*configFile)
|
2019-06-16 18:11:10 +00:00
|
|
|
if err != nil {
|
|
|
|
log.Fatalln(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
rgbLEDs := make([]rgbled.RGBLED, 0)
|
|
|
|
if len(args) != 0 {
|
|
|
|
rgbLEDs = cnf.GetRGBLEDsByName(args)
|
|
|
|
} else {
|
|
|
|
rgbLEDs = cnf.GetRGBLEDs(config.ENABLED)
|
|
|
|
}
|
|
|
|
|
|
|
|
err = rgbled.Off(rgbLEDs)
|
|
|
|
if err != nil {
|
|
|
|
log.Fatalln(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
rgbLedCmd.AddCommand(offRgbLedCmd)
|
|
|
|
}
|