-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathcli.js
executable file
·46 lines (41 loc) · 929 Bytes
/
cli.js
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
#!/usr/bin/env node
const lib = require('.');
const options = require('options-parser');
const fs = require('fs');
const opts = {
width: {
short: 'w',
default: 800,
varName: '800',
help: 'width of the generated image'
},
height: {
short: 'h',
default: 600,
varName: '600',
help: 'height of the generated image'
},
out: {
short: 'o',
varName: 'out.svg',
type: options.type.file.open.write(),
help: 'name of the output file'
},
help: {
short: 'h',
help: 'this help screen',
showHelp: {
banner: 'procedural-strings-js example: [options]'
}
}
};
const result = options.parse(opts);
if(!result.opt.out){
options.help(opts);
process.exit();
}
const setting = new lib.Settings();
setting.width = result.opt.width;
setting.height = result.opt.height;
const data = lib.generate(setting);
fs.writeFileSync(result.opt.out.fd, data);