forked from arusanov/avatar-generator
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcli.js
More file actions
executable file
·33 lines (25 loc) · 919 Bytes
/
Copy pathcli.js
File metadata and controls
executable file
·33 lines (25 loc) · 919 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
#! /usr/bin/env node
'use strict';
var avatar = require('./lib/avatar-generator')();
var program = require('commander');
function checkDiscriminator(value) {
return generator.discriminators.indexOf(value)!==-1;
}
program
.version(require('./package').version)
.option('-I, --id <id>', 'id for avatar. any string')
.option('-D, --discriminator [value]', 'avatar discriminator (one of: ' + generator.discriminators.join(', ') + ')', 'male',checkDiscriminator)
.option('-S, --size <width>', 'avatar size', parseInt, 400)
.option('*')
.parse(process.argv);
try {
var out = process.stdout;
if (program['*'] && Array.isArray(program['*']) && program['*'].length>0){
out = require('fs').createWriteStream(program['*'][0]);
}
generator(program.id, program.discriminator, program.size).stream().pipe(out);
}
catch (err) {
console.error(err);
program.help();
}