func (cmd CreateQuota) Run(context *cli.Context) { name := context.Args()[0] cmd.ui.Say("Creating quota %s as %s...", terminal.EntityNameColor(name), terminal.EntityNameColor(cmd.config.Username())) quota := models.QuotaFields{ Name: name, } memoryLimit := context.String("m") if memoryLimit != "" { parsedMemory, err := formatters.ToMegabytes(memoryLimit) if err != nil { cmd.ui.Failed("Invalid memory limit: %s\n%s", memoryLimit, err) } quota.MemoryLimit = parsedMemory } if context.IsSet("r") { quota.RoutesLimit = context.Int("r") } if context.IsSet("s") { quota.ServicesLimit = context.Int("s") } if context.IsSet("allow-paid-service-plans") { quota.NonBasicServicesAllowed = true } err := cmd.quotaRepo.Create(quota) httpErr, ok := err.(errors.HttpError) if ok && httpErr.ErrorCode() == errors.QUOTA_EXISTS { cmd.ui.Ok() cmd.ui.Warn("Quota Definition %s already exists", quota.Name) return } if err != nil { cmd.ui.Failed(err.Error()) } cmd.ui.Ok() }