(ctx context.Context, rep repo.DirectRepository)
| 29 | } |
| 30 | |
| 31 | func (c *commandIndexList) run(ctx context.Context, rep repo.DirectRepository) error { |
| 32 | var jl jsonList |
| 33 | |
| 34 | jl.begin(&c.jo) |
| 35 | defer jl.end() |
| 36 | |
| 37 | blks, err := rep.IndexBlobs(ctx, c.blockIndexListIncludeSuperseded) |
| 38 | if err != nil { |
| 39 | return errors.Wrap(err, "error listing index blobs") |
| 40 | } |
| 41 | |
| 42 | switch c.blockIndexListSort { |
| 43 | case "time": |
| 44 | sort.Slice(blks, func(i, j int) bool { |
| 45 | return blks[i].Timestamp.Before(blks[j].Timestamp) |
| 46 | }) |
| 47 | case "size": |
| 48 | sort.Slice(blks, func(i, j int) bool { |
| 49 | return blks[i].Length < blks[j].Length |
| 50 | }) |
| 51 | case "name": |
| 52 | sort.Slice(blks, func(i, j int) bool { |
| 53 | return blks[i].BlobID < blks[j].BlobID |
| 54 | }) |
| 55 | } |
| 56 | |
| 57 | for _, b := range blks { |
| 58 | if c.jo.jsonOutput { |
| 59 | jl.emit(b) |
| 60 | } else { |
| 61 | c.out.printStdout("%-60v %10v %v %v\n", b.BlobID, b.Length, formatTimestampPrecise(b.Timestamp), b.Superseded) |
| 62 | } |
| 63 | } |
| 64 | |
| 65 | if c.blockIndexListSummary && !c.jo.jsonOutput { |
| 66 | c.out.printStdout("total %v indexes\n", len(blks)) |
| 67 | } |
| 68 | |
| 69 | return nil |
| 70 | } |
nothing calls this directly
no test coverage detected