func (cmd DeleteOrphanedRoutes) Run(c *cli.Context) { force := c.Bool("f") if !force { response := cmd.ui.Confirm(T("Really delete orphaned routes?{{.Prompt}}", map[string]interface{}{"Prompt": terminal.PromptColor(">")})) if !response { return } } cmd.ui.Say(T("Getting routes as {{.Username}} ...\n", map[string]interface{}{"Username": terminal.EntityNameColor(cmd.config.Username())})) apiErr := cmd.routeRepo.ListRoutes(func(route models.Route) bool { if len(route.Apps) == 0 { cmd.ui.Say(T("Deleting route {{.Route}}...", map[string]interface{}{"Route": terminal.EntityNameColor(route.Host + "." + route.Domain.Name)})) apiErr := cmd.routeRepo.Delete(route.Guid) if apiErr != nil { cmd.ui.Failed(apiErr.Error()) return false } } return true }) if apiErr != nil { cmd.ui.Failed(T("Failed fetching routes.\n{{.Err}}", map[string]interface{}{"Err": apiErr.Error()})) return } cmd.ui.Ok() }
func (ui *FakeUI) ConfirmDelete(modelType, modelName string) bool { return ui.Confirm( "Really delete the %s %s?%s", modelType, term.EntityNameColor(modelName), term.PromptColor(">")) }