|
@ -76,17 +76,33 @@ func handlerCmd( |
|
|
|
|
|
|
|
|
WriteHandlerInfoTable(os.Stdout, []models.EventHandler{*returned}) |
|
|
WriteHandlerInfoTable(os.Stdout, []models.EventHandler{*returned}) |
|
|
case "delete": |
|
|
case "delete": |
|
|
id := cmd.Params.Get(0).Int() |
|
|
|
|
|
if id == nil { |
|
|
|
|
|
log.Fatalln("ID missing") |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
if cmd.Params.Get(0).StringOr("_not") == "all" { |
|
|
|
|
|
handlers, err := c.GetHandlers(ctx) |
|
|
|
|
|
if err != nil { |
|
|
|
|
|
log.Fatalln(err) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
handler, err := c.DeleteHandler(ctx, *id) |
|
|
|
|
|
if err != nil { |
|
|
|
|
|
log.Fatalln(err) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
for _, handler := range handlers { |
|
|
|
|
|
_, err = c.DeleteHandler(ctx, handler.ID) |
|
|
|
|
|
if err != nil { |
|
|
|
|
|
log.Fatalln(err) |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
WriteHandlerInfoTable(os.Stdout, []models.EventHandler{*handler}) |
|
|
|
|
|
|
|
|
log.Printf("Deleted %d handlers", len(handlers)) |
|
|
|
|
|
} else { |
|
|
|
|
|
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: |
|
|
default: |
|
|
if cmd.Name != "help" { |
|
|
if cmd.Name != "help" { |
|
|
log.Println("Unknown command:", cmd.Name) |
|
|
log.Println("Unknown command:", cmd.Name) |
|
|