package main import ( "context" "fmt" "git.aiterp.net/lucifer/new-server/app/client" "git.aiterp.net/lucifer/new-server/models" "log" "os" ) func handlerCmd( ctx context.Context, c client.Client, ) { cmd := parseCommand(os.Args[2:]) switch cmd.Name { case "list": handlers, err := c.GetHandlers(ctx, cmd.Params.Get(0).StringOr("all")) if err != nil { log.Fatalln(err) } WriteHandlerInfoTable(os.Stdout, handlers) case "delete": id := cmd.Params.Get(0).Int() if id == nil { log.Fatalln("ID missing") } handler, err := c.DeleteHandler(ctx, *id) if err != nil { log.Fatalln(err) } WriteHandlerInfoTable(os.Stdout, []models.EventHandler{*handler}) default: if cmd.Name != "help" { log.Println("Unknown command:", cmd.Name) } _, _ = fmt.Fprintln(os.Stderr, helpString[1:]) } }