2019-06-16 11:00:50 +00:00
|
|
|
package rgbled
|
|
|
|
|
|
|
|
import (
|
|
|
|
"log"
|
|
|
|
|
|
|
|
"github.com/go-flucky/flucky/pkg/config"
|
|
|
|
"github.com/spf13/cobra"
|
|
|
|
)
|
|
|
|
|
|
|
|
var removeRgbLedCmd = &cobra.Command{
|
|
|
|
Use: "remove",
|
|
|
|
Short: "Remove a RGB-LED",
|
|
|
|
Example: `flucky rgb-led remove <name/uuid>
|
|
|
|
flucky rgb-led remove my-led
|
|
|
|
flucky rgb-led remove 9f8abfc5-91f3-480c-a42d-b990b6f89e5d`,
|
|
|
|
Aliases: []string{"rm"},
|
|
|
|
Args: cobra.ExactArgs(1),
|
|
|
|
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 11:00:50 +00:00
|
|
|
if err != nil {
|
|
|
|
log.Fatalln(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
// // add remote entry to list
|
|
|
|
err = cnf.RemoveRGBLED(args[0])
|
|
|
|
if err != nil {
|
|
|
|
log.Fatalln(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
// save new configuration
|
2019-08-19 10:24:08 +00:00
|
|
|
err = config.Write(cnf, *configFile)
|
2019-06-16 11:00:50 +00:00
|
|
|
if err != nil {
|
|
|
|
log.Fatalln(err)
|
|
|
|
}
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
rgbLedCmd.AddCommand(removeRgbLedCmd)
|
|
|
|
}
|