(c flags.FlagContext)
| 53 | } |
| 54 | |
| 55 | func (cmd *RouterGroups) Execute(c flags.FlagContext) error { |
| 56 | cmd.ui.Say(T("Getting router groups as {{.Username}} ...\n", |
| 57 | map[string]interface{}{"Username": terminal.EntityNameColor(cmd.config.Username())})) |
| 58 | |
| 59 | table := cmd.ui.Table([]string{T("name"), T("type")}) |
| 60 | |
| 61 | noRouterGroups := true |
| 62 | cb := func(group models.RouterGroup) bool { |
| 63 | noRouterGroups = false |
| 64 | table.Add(group.Name, group.Type) |
| 65 | return true |
| 66 | } |
| 67 | |
| 68 | apiErr := cmd.routingAPIRepo.ListRouterGroups(cb) |
| 69 | if apiErr != nil { |
| 70 | return errors.New(T("Failed fetching router groups.\n{{.Err}}", map[string]interface{}{"Err": apiErr.Error()})) |
| 71 | } |
| 72 | |
| 73 | if noRouterGroups { |
| 74 | cmd.ui.Say(T("No router groups found")) |
| 75 | } |
| 76 | |
| 77 | err := table.Print() |
| 78 | if err != nil { |
| 79 | return err |
| 80 | } |
| 81 | return nil |
| 82 | } |
nothing calls this directly
no test coverage detected