You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
60 lines
1.2 KiB
60 lines
1.2 KiB
package commands
|
|
|
|
import (
|
|
"fmt"
|
|
"git.aiterp.net/lucifer3/server/internal/formattools"
|
|
"strings"
|
|
)
|
|
|
|
type PairDevice struct {
|
|
ID string `json:"id"`
|
|
}
|
|
|
|
func (c PairDevice) CommandDescription() string {
|
|
return fmt.Sprintf("PairDevice(%s)", c.ID)
|
|
}
|
|
|
|
func (c PairDevice) Matches(driver string) (sub string, ok bool) {
|
|
split := strings.SplitN(c.ID, ":", 2)
|
|
if split[0] != driver {
|
|
return "", false
|
|
}
|
|
|
|
return split[1], true
|
|
}
|
|
|
|
type ConnectDevice struct {
|
|
ID string `json:"id"`
|
|
APIKey string `json:"apiKey"`
|
|
}
|
|
|
|
func (c ConnectDevice) Matches(driver string) (sub string, ok bool) {
|
|
split := strings.SplitN(c.ID, ":", 2)
|
|
if split[0] != driver {
|
|
return "", false
|
|
}
|
|
|
|
return split[1], true
|
|
}
|
|
|
|
func (c ConnectDevice) CommandDescription() string {
|
|
return fmt.Sprintf("ConnectDevice(%s, %s)", c.ID, formattools.Asterisks(c.APIKey))
|
|
}
|
|
|
|
type SearchDevices struct {
|
|
ID string `json:"id"`
|
|
Hint string `json:"hint"`
|
|
}
|
|
|
|
func (c SearchDevices) Matches(driver string) (string, bool) {
|
|
split := strings.SplitN(c.ID, ":", 2)
|
|
if split[0] != driver {
|
|
return "", false
|
|
}
|
|
|
|
return split[1], true
|
|
}
|
|
|
|
func (c SearchDevices) CommandDescription() string {
|
|
return fmt.Sprintf("SearchDevices(%s, %#+v)", c.ID, c.Hint)
|
|
}
|