dump-db.js 1.2 KB

123456789101112131415161718192021222324252627282930313233
  1. #!/usr/bin/env node
  2. const yargs = require('yargs/yargs')
  3. const { hideBin } = require('yargs/helpers')
  4. const dumpService = require("./inc/dump");
  5. yargs(hideBin(process.argv))
  6. .command('$0 <path_to_document> <target_directory>', 'dump the contents of document.db into the target directory', (yargs) => {
  7. return yargs
  8. .positional('path_to_document', { describe: 'path to the document.db' })
  9. .positional('target_directory', { describe: 'path of the directory into which the notes should be dumped' })
  10. }, (argv) => {
  11. try {
  12. dumpService.dumpDocument(argv.path_to_document, argv.target_directory, {
  13. includeDeleted: argv.includeDeleted,
  14. password: argv.password
  15. });
  16. }
  17. catch (e) {
  18. console.error(`Unrecoverable error:`, e);
  19. process.exit(1);
  20. }
  21. })
  22. .option('password', {
  23. type: 'string',
  24. description: 'Set password to be able to decrypt protected notes.'
  25. })
  26. .option('include-deleted', {
  27. type: 'boolean',
  28. default: false,
  29. description: 'If set to true, dump also deleted notes.'
  30. })
  31. .parse();