address_book.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. module.exports.name = 'address_book'
  2. module.exports.description = 'List all address book records contained in the backup.'
  3. // Specify this reporter requires a backup.
  4. // The second parameter to func() is now a backup instead of the path to one.
  5. module.exports.requiresBackup = true
  6. // Specify this reporter supports the promises API for allowing chaining of reports.
  7. module.exports.usesPromises = true
  8. module.exports.func = function (program, backup, resolve, reject) {
  9. backup.getAddressBook()
  10. .then((items) => {
  11. // Use the configured formatter to print the rows.
  12. const result = program.formatter.format(items, {
  13. // Color formatting?
  14. program: program,
  15. // Columns to be displayed in human-readable printouts.
  16. // Some formatters, like raw or CSV, ignore these.
  17. columns: {
  18. 'ID': el => el.ROWID,
  19. 'First': el => el.First ? el.First.substring(0, 10) + '' : '',
  20. 'Last': el => el.Last ? el.Last.substring(0, 10) + '' : '',
  21. 'Organization': el => el.organization ? el.organization.substring(0, 10) + '' : '',
  22. 'Phone Work': el => el.phone_work ? el.phone_work.substring(0, 14) + '' : '',
  23. 'Phone Mobile': el => el.phone_mobile ? el.phone_mobile.substring(0, 14) + '' : '',
  24. 'Phone Home': el => el.phone_home ? el.phone_home.substring(0, 14) + '' : '',
  25. 'Email': el => el.email ? el.email.substring(0, 28) + '' : '',
  26. 'Created Date': el => el.created_date ? el.created_date.substring(0, 28) + '' : '',
  27. 'Note': el => el.note ? el.note.substring(0, 28) + '' : '',
  28. 'Picture': el => el.profile_picture ? 1 : 0
  29. }
  30. })
  31. // If using promises, we must call resolve()
  32. resolve(result)
  33. })
  34. .catch(reject)
  35. }