PrintIterator prints the objects returned by an object iterator.
(it *vt.Iterator)
| 223 | |
| 224 | // PrintIterator prints the objects returned by an object iterator. |
| 225 | func (p *Printer) PrintIterator(it *vt.Iterator) error { |
| 226 | var objs []*vt.Object |
| 227 | var ids []string |
| 228 | for it.Next() { |
| 229 | obj := it.Get() |
| 230 | if viper.GetBool("identifiers-only") { |
| 231 | ids = append(ids, obj.ID()) |
| 232 | } else { |
| 233 | objs = append(objs, obj) |
| 234 | } |
| 235 | } |
| 236 | if err := it.Error(); err != nil { |
| 237 | return err |
| 238 | } |
| 239 | |
| 240 | if viper.GetBool("identifiers-only") { |
| 241 | if err := p.Print(ids); err != nil { |
| 242 | return err |
| 243 | } |
| 244 | } else { |
| 245 | if err := p.PrintObjects(objs); err != nil { |
| 246 | return err |
| 247 | } |
| 248 | } |
| 249 | p.PrintCommandLineWithCursor(it) |
| 250 | return nil |
| 251 | } |
| 252 | |
| 253 | // PrintCommandLineWithCursor prints the same command-line that was used for |
| 254 | // executing the program but adding or replacing the --cursor flag with |
no test coverage detected