您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 
 
 

65 行
1.9 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.encryptLogin(login, masterPassword).then(function (encryptedLogin) {
  31. lesspass.renderPassword(encryptedLogin, site, options).then(function (generatedPassword) {
  32. console.log(generatedPassword);
  33. });
  34. });
  35. }
  36. var lowercase = (cli.flags.lowercase || 'true').toLowerCase() === 'true';
  37. var uppercase = (cli.flags.uppercase || 'true').toLowerCase() === 'true';
  38. var symbols = (cli.flags.symbols || 'true').toLowerCase() === 'true';
  39. var numbers = (cli.flags.numbers || 'true').toLowerCase() === 'true';
  40. var options = {
  41. counter: cli.flags.counter || 1,
  42. length: cli.flags.length || 12,
  43. lowercase: lowercase,
  44. uppercase: uppercase,
  45. numbers: numbers,
  46. symbols: symbols
  47. };
  48. var site = cli.input[0];
  49. var login = cli.input[1];
  50. if (cli.input.length === 3) {
  51. var masterPassword = cli.input[2];
  52. calcPassword(site, login, masterPassword, options)
  53. } else {
  54. read({prompt: 'master password: ', silent: true}, function (er, password) {
  55. calcPassword(site, login, password, options)
  56. });
  57. }