Browse Source

enable 'lucy handler delete all'

feature-colorvalue2
Stian Fredrik Aune 3 years ago
parent
commit
f4e584938b
  1. 16
      cmd/lucy/handlercmd.go

16
cmd/lucy/handlercmd.go

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

Loading…
Cancel
Save