-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathexport.js
More file actions
executable file
·41 lines (35 loc) · 1.1 KB
/
export.js
File metadata and controls
executable file
·41 lines (35 loc) · 1.1 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
#!/usr/bin/env node
var program = require('commander'),
Import = require('./lib/import'),
fs = require('fs'),
path = require('path'),
contentType,
inputStream,
outputStream;
program
.version('0.0.2')
.usage('-t type')
.option('-t, --type [type]', 'peg filter to apply. default: movie', 'movies')
.option('-p, --print', 'print results to STDOUT.')
.option('-i, --input', 'accept input from STDIN.')
.option('-f, --from [filename]', 'read from the [filename]')
.option('-o, --output [filename]', 'write results to this file.')
.parse(process.argv);
contentType = program.type;
if(program.print){
outputStream = process.stdout;
} else {
var outputFile = path.resolve(program.output);
outputStream = fs.createWriteStream(outputFile);
}
if(program.input){
inputStream = process.stdin;
} else if(program.from){
inputStream = fs.createReadStream(path.resolve(program.from));
} else {
inputStream = fs.createReadStream('./tmp/'+contentType+'.list');
}
if(!outputStream){
console.error('please chose the output stream/file');
}
var toggleImport = new Import(inputStream, contentType, outputStream);