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.

32 lines
535 B

  1. package main
  2. import (
  3. "context"
  4. "fmt"
  5. "git.aiterp.net/lucifer/new-server/app/client"
  6. "log"
  7. "os"
  8. )
  9. func handlerCmd(
  10. ctx context.Context,
  11. c client.Client,
  12. ) {
  13. cmd := parseCommand(os.Args[2:])
  14. switch cmd.Name {
  15. case "list":
  16. handlers, err := c.GetHandlers(ctx, cmd.Params.Get(0).StringOr("all"))
  17. if err != nil {
  18. log.Fatalln(err)
  19. }
  20. WriteHandlerInfoTable(os.Stdout, handlers)
  21. default:
  22. if cmd.Name != "help" {
  23. log.Println("Unknown command:", cmd.Name)
  24. }
  25. _, _ = fmt.Fprintln(os.Stderr, helpString[1:])
  26. }
  27. }