Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
 
 
 
 
 
 

63 righe
1.8 KiB

  1. #!/usr/bin/env node
  2. 'use strict';
  3. var meow = require('meow');
  4. var LessPass = require('lesspass');
  5. var read = require('read');
  6. var cli = meow(`
  7. Usage
  8. $ lesspass <site> <login> <masterPassword>
  9. Options
  10. --lowercase, -l true or false (default true)
  11. --uppercase, -u true or false (default true)
  12. --symbols, -s true or false (default true)
  13. --numbers, -n true or false (default true)
  14. --length, -L int (default 12)
  15. --counter, -c int (default 1)
  16. Examples
  17. $ lesspass lesspass.com contact@lesspass.com 'my Master Password' --length=14 -s=false
  18. onAV7eqIM1arOZ
  19. `, {
  20. alias: {
  21. l: 'lowercase',
  22. u: 'uppercase',
  23. s: 'symbols',
  24. n: 'numbers',
  25. L: 'length',
  26. c: 'counter',
  27. }
  28. });
  29. function calcPassword(site, login, masterPassword, options) {
  30. LessPass.generatePassword(site, login, masterPassword, options).then(generatedPassword => {
  31. console.log(generatedPassword);
  32. });
  33. }
  34. var lowercase = (cli.flags.lowercase || 'true').toLowerCase() === 'true';
  35. var uppercase = (cli.flags.uppercase || 'true').toLowerCase() === 'true';
  36. var symbols = (cli.flags.symbols || 'true').toLowerCase() === 'true';
  37. var numbers = (cli.flags.numbers || 'true').toLowerCase() === 'true';
  38. var options = {
  39. counter: cli.flags.counter || 1,
  40. length: cli.flags.length || 16,
  41. lowercase: lowercase,
  42. uppercase: uppercase,
  43. numbers: numbers,
  44. symbols: symbols
  45. };
  46. var site = cli.input[0];
  47. var login = cli.input[1];
  48. if (cli.input.length === 3) {
  49. var masterPassword = cli.input[2];
  50. calcPassword(site, login, masterPassword, options)
  51. } else {
  52. read({prompt: 'master password: ', silent: true}, function (er, password) {
  53. calcPassword(site, login, password, options)
  54. });
  55. }