-
Notifications
You must be signed in to change notification settings - Fork 0
/
cli.js
executable file
·54 lines (44 loc) · 1.17 KB
/
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
47
48
49
50
51
52
53
54
#!/usr/bin/env node
var program = require("commander");
var flusso = require(".");
let fcsParser = flusso.fcsParser;
program.version("0.1.2");
program
.command("json <fcsFile>")
.description("converts the FCS file into JSON format")
.action(fcsFile => {
let fcs = fcsParser.fromFile(fcsFile);
console.log(JSON.stringify(fcs));
});
program
.command("tsv <fcsFile>")
.description("converts the FCS file into TSV format")
.action(fcsFile => {
let fcs = fcsParser.fromFile(fcsFile);
let tsvHeader = "FileName";
for (i = 1; i <= fcs.TEXT._PAR; i++) {
tsvHeader += "\t" + fcs.TEXT[`_P${i}N`];
}
console.log(tsvHeader);
for (i = 0; i < fcs.DATA.length; i++) {
let eventData = fcs.DATA[i].join("\t");
process.stdout.write(`${fcsFile}\t${eventData}\n`);
}
});
program
.command("validate <fcsFile>")
.description("parses the file and exits")
.action(fcsFile => {
// Just parse and do nothing
fcsParser.fromFile(fcsFile);
});
program
.command("*")
.description("prints help and exits")
.action(() => {
program.help();
});
program.parse(process.argv);
if (program.args.length < 1) {
program.help();
}