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.
 
 
 
 
 
 

61 lines
1.3 KiB

package commands
import (
"fmt"
"git.aiterp.net/lucifer3/server/internal/formattools"
"strings"
)
type PairDevice struct {
ID string `json:"id"`
APIKey string `json:"apiKey"`
}
func (c PairDevice) CommandDescription() string {
return fmt.Sprintf("PairDevice(%s, %s)", c.ID, formattools.Asterisks(c.APIKey))
}
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)
}