riglist.go 808 B

12345678910111213141516171819202122232425262728293031323334353637
  1. // Copyright 2016 Martin Hebnes Pedersen (LA5NTA). All rights reserved.
  2. // Use of this source code is governed by the MIT-license that can be
  3. // found in the LICENSE file.
  4. // +build libhamlib
  5. package main
  6. import (
  7. "fmt"
  8. "strings"
  9. "github.com/la5nta/wl2k-go/rigcontrol/hamlib"
  10. )
  11. func init() {
  12. cmd := Command{
  13. Str: "riglist",
  14. Usage: "[search term]",
  15. Desc: "Print/search a list of rigcontrol supported transceivers.",
  16. HandleFunc: riglistHandle,
  17. }
  18. commands = append(commands[:8], append([]Command{cmd}, commands[8:]...)...)
  19. }
  20. func riglistHandle(args []string) {
  21. term := strings.ToLower(args[0])
  22. fmt.Print("id\ttransceiver\n")
  23. for m, str := range hamlib.Rigs() {
  24. if !strings.Contains(strings.ToLower(str), term) {
  25. continue
  26. }
  27. fmt.Printf("%d\t%s\n", m, str)
  28. }
  29. }