// usersDel delete an user func usersDel(w http.ResponseWriter, r *http.Request) { if !authorized(w, r) { return } err := api.UserDel(httpcontext.Get(r, "params").(httprouter.Params).ByName("user")) if err == gorm.RecordNotFound { httpWriteErrorJson(w, 404, "no such user "+httpcontext.Get(r, "params").(httprouter.Params).ByName("user"), err.Error()) return } if err != nil { httpWriteErrorJson(w, 500, "unable to del user "+httpcontext.Get(r, "params").(httprouter.Params).ByName("user"), err.Error()) return } }
} err = api.UserAdd(c.Args()[0], c.Args()[1], c.String("q"), c.Bool("m"), c.Bool("r"), c.Bool("catchall")) cliHandleErr(err) cliDieOk() }, }, { Name: "del", Usage: "Delete an user", Description: "tmail user del USER", Action: func(c *cgCli.Context) { var err error if len(c.Args()) != 1 { cliDieBadArgs(c) } err = api.UserDel(c.Args()[0]) cliHandleErr(err) cliDieOk() }, }, { Name: "list", Usage: "Return a list of users", Description: "", Action: func(c *cgCli.Context) { users, err := api.UserGetAll() cliHandleErr(err) if len(users) == 0 { println("There is no users yet.") return }