-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
executable file
·44 lines (32 loc) · 1.14 KB
/
index.js
File metadata and controls
executable file
·44 lines (32 loc) · 1.14 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
#!/usr/bin/env node
import chalk from "chalk";
import clipboardy from "clipboardy";
import { program } from "commander";
import createPassword from "./utils/createPassword.js";
import savePassword from "./utils/savePassword.js";
const log = console.log;
program.version("1.0.0").description("Simple Password Generator");
program
.option("-l, --length <number>", "length of password", 20)
.option("-s, --save", "save password to passwords.txt")
.option("-n0, --nonumbers", "remove numbers", false)
.option("-sy, --symbols", "include symbols", false)
.parse();
const { length, save, nonumbers, symbols } = program.opts();
// Generate password
const generatedPassword = createPassword(length, nonumbers, symbols);
if (save) {
savePassword(generatedPassword);
}
clipboardy.writeSync(generatedPassword);
log(chalk.green("Generated Password: ") + chalk.bold(generatedPassword));
log(chalk.yellow("Password copied to clipboard "));
// console.log(program.opts())
// Can create commands and actions on the
// program using Commander.js
// program
// .command('generate')
// .action(() => {
// console.log("Generated")
// })
// .parse()