42 lines
812 B
Go
42 lines
812 B
Go
|
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
|
||
|
cnf, err := config.Read(configFile)
|
||
|
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
|
||
|
err = config.Write(cnf, configFile)
|
||
|
if err != nil {
|
||
|
log.Fatalln(err)
|
||
|
}
|
||
|
},
|
||
|
}
|
||
|
|
||
|
func init() {
|
||
|
rgbLedCmd.AddCommand(removeRgbLedCmd)
|
||
|
}
|