(ctx context.Context, rep repo.Repository)
| 24 | } |
| 25 | |
| 26 | func (c *commandNotificationTemplateList) run(ctx context.Context, rep repo.Repository) error { |
| 27 | infos, err := notifytemplate.ListTemplates(ctx, rep, "") |
| 28 | if err != nil { |
| 29 | return errors.Wrap(err, "error listing templates") |
| 30 | } |
| 31 | |
| 32 | sort.Slice(infos, func(i, j int) bool { |
| 33 | return infos[i].Name < infos[j].Name |
| 34 | }) |
| 35 | |
| 36 | var jl jsonList |
| 37 | |
| 38 | if c.jo.jsonOutput { |
| 39 | jl.begin(&c.jo) |
| 40 | defer jl.end() |
| 41 | } |
| 42 | |
| 43 | c.out.printStdout("%-30v %-15v %v\n", "NAME", "TYPE", "MODIFIED") |
| 44 | |
| 45 | for _, i := range infos { |
| 46 | if c.jo.jsonOutput { |
| 47 | jl.emit(i) |
| 48 | continue |
| 49 | } |
| 50 | |
| 51 | var typeString, lastModString string |
| 52 | |
| 53 | if i.LastModified == nil { |
| 54 | typeString = "<built-in>" |
| 55 | lastModString = "" |
| 56 | } else { |
| 57 | typeString = "<customized>" |
| 58 | lastModString = formatTimestamp(*i.LastModified) |
| 59 | } |
| 60 | |
| 61 | c.out.printStdout("%-30v %-15v %v\n", i.Name, typeString, lastModString) |
| 62 | } |
| 63 | |
| 64 | return nil |
| 65 | } |
nothing calls this directly
no test coverage detected