-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
51 lines (40 loc) · 1.28 KB
/
index.js
File metadata and controls
51 lines (40 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/env node
const program = require('commander');
const chalk = require('chalk');
const clipboardy = require('clipboardy');
const showBanner = require('node-banner');
const createPassword = require('./utils/createPassword');
const savePassword = require('./utils/savePassword');
program.version('1.0.0').description('Password Generator');
program
.option('-l, --length <number>', 'length of password', '8')
.option('-s, --save', 'save password to passwords.txt')
.option('-nn, --no-numbers', 'remove numbers')
.option('-ns, --no-symbols', 'remove symbols')
.parse();
//getting the values from CLI object
const { length, save, numbers, symbols } = program.opts();
//
(async () => {
await showBanner(
'PASGEN',
'Generates safe and secure password for you\n',
'green',
'green',
);
setTimeout(() => {
//generate password
const generatedPassword = createPassword(length, numbers, symbols);
//Save to file
if (save) {
savePassword(generatedPassword);
}
//copy to clipboard
clipboardy.writeSync(generatedPassword);
//output generated password
console.log(
chalk.blueBright('Generated Password: ') + chalk.bold(generatedPassword),
);
console.log(chalk.yellow('Password copied to clipboard 📋'));
}, 500);
})();