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

  1. package commands
  2. import (
  3. "fmt"
  4. "git.aiterp.net/lucifer3/server/internal/formattools"
  5. "strings"
  6. )
  7. type PairDevice struct {
  8. ID string `json:"id"`
  9. }
  10. func (c PairDevice) CommandDescription() string {
  11. return fmt.Sprintf("PairDevice(%s)", c.ID)
  12. }
  13. func (c PairDevice) Matches(driver string) (sub string, ok bool) {
  14. split := strings.SplitN(c.ID, ":", 2)
  15. if split[0] != driver {
  16. return "", false
  17. }
  18. return split[1], true
  19. }
  20. type ConnectDevice struct {
  21. ID string `json:"id"`
  22. APIKey string `json:"apiKey"`
  23. }
  24. func (c ConnectDevice) Matches(driver string) (sub string, ok bool) {
  25. split := strings.SplitN(c.ID, ":", 2)
  26. if split[0] != driver {
  27. return "", false
  28. }
  29. return split[1], true
  30. }
  31. func (c ConnectDevice) CommandDescription() string {
  32. return fmt.Sprintf("ConnectDevice(%s, %s)", c.ID, formattools.Asterisks(c.APIKey))
  33. }
  34. type SearchDevices struct {
  35. ID string `json:"id"`
  36. Hint string `json:"hint"`
  37. }
  38. func (c SearchDevices) Matches(driver string) (string, bool) {
  39. split := strings.SplitN(c.ID, ":", 2)
  40. if split[0] != driver {
  41. return "", false
  42. }
  43. return split[1], true
  44. }
  45. func (c SearchDevices) CommandDescription() string {
  46. return fmt.Sprintf("SearchDevices(%s, %#+v)", c.ID, c.Hint)
  47. }