forked from Lilly-Protocol/lily-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcli.js
More file actions
executable file
·34 lines (34 loc) · 1005 Bytes
/
Copy pathcli.js
File metadata and controls
executable file
·34 lines (34 loc) · 1005 Bytes
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
#!/usr/bin/env node
import { humanId } from "./index.js";
// @ts-ignore
const args = process.argv.slice(2);
const options = {
adjectiveCount: 1,
addAdverb: false,
separator: '',
capitalize: true
};
const adverb = ['a', 'adverb', 'addadverb'];
const lower = ['l', 'lower', 'lowercase'];
let reps = 1;
for (const arg of args) {
if (String(parseInt(arg)) === String(arg))
options.adjectiveCount = parseInt(arg);
else if (typeof arg === 'string') {
const lc = arg.toLowerCase();
if (adverb.includes(lc))
options.addAdverb = true;
else if (lower.includes(lc))
options.capitalize = false;
else if (lc.endsWith('x'))
reps = parseInt(arg);
else if (lc === 'space')
options.separator = ' ';
else if (!options.separator && arg.length === 1)
options.separator = arg;
}
}
for (let i = 0; i < reps; i++) {
console.log(humanId(options));
}
//# sourceMappingURL=cli.js.map