-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathargp.js
48 lines (47 loc) · 1.09 KB
/
argp.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
function gen(args) {
let cf = {
file: "",
sampleRate: 32000,
output: "out.bin",
useFFmpeg: false,
ffmpegArg: ["", ""],
help: false,
plugin: false,
pluginPath: ""
};
let parami = []
function check(i){
for(let j = 0; j < parami.length; j++){
if(parami[j] == i) return true;
};
}
args.forEach((v, i) => {
if (i <= 1) return;
if (check(i)) return;
if (v == "--sampleRate" || v == "-r") {
cf.sampleRate = parseInt(args[i + 1]);
parami.push(i+1)
} else if (v == "--help" || v == "-h") {
cf.help = true;
} else if (v == "--output" || v == "-o") {
cf.output = args[i + 1];
parami.push(i+1)
} else if (v == "--ffmpeg") {
cf.useFFmpeg = true;
} else if (v == "-fi") {
cf.ffmpegArg[0] = args[i + 1];
parami.push(i+1)
} else if (v == "-fo") {
cf.ffmpegArg[1] = args[i + 1];
parami.push(i+1)
} else if(v == "-p"){
cf.plugin = true
cf.pluginPath = args[i+1]
parami.push(i+1)
} else {
cf.file = v;
}
});
return cf;
}
module.exports = gen;