PKGBUILD/cmd/rgbled/enable.go

42 lines
785 B
Go
Raw Normal View History

package rgbled
import (
"log"
"github.com/go-flucky/flucky/pkg/config"
"github.com/spf13/cobra"
)
var enableRgbLedCmd = &cobra.Command{
Use: "enable",
Short: "Enable a RGB-LED",
Example: `flucky rgb-led enable <name/uuid>
flucky rgb-led enable my-led
flucky rgb-led enable 9f8abfc5-91f3-480c-a42d-b990b6f89e5d`,
Args: cobra.ExactArgs(1),
Run: func(cmd *cobra.Command, args []string) {
// read configuration
cnf, err := config.Read(configFile)
if err != nil {
log.Fatalln(err)
}
// disable sensor entry to list
err = cnf.EnableRGBLED(args[0])
if err != nil {
log.Fatalln(err)
}
// save new configuration
err = config.Write(cnf, configFile)
if err != nil {
log.Fatalln(err)
}
},
}
func init() {
rgbLedCmd.AddCommand(enableRgbLedCmd)
}