This repository has been archived by the owner on May 20, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
yargs.ts
84 lines (79 loc) · 2.94 KB
/
yargs.ts
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
import * as yargs from 'yargs';
import fs from 'fs';
import { ProgrammSettingsInterface } from './interfaces';
import path from 'path';
const argv = yargs
.option('Video Directory', {
alias: 'vd',
describe: 'The Directory Path were your videos are',
requiresArg: true,
string: true
})
.option('debug', {
boolean: true,
default: false,
hidden: true
})
.option('Working Directory', {
string: true,
default: __dirname,
hidden: true,
describe: 'Dont change if you dont know what you are doing!\nYou can change the working directory if you need it.',
alias: 'wd'
})
.option('beta', {
boolean: true,
default: false,
describe: 'Set this to true if you want to download beta versions!'
})
.option('shutup', {
boolean: true,
default: false,
describe: 'Don\'t want the star advert? Remove it with this flag!',
alias: 's',
})
.option('httpPort', {
number: true,
default: 80,
describe: 'The port to pind the http server to'
})
.option('httpsPort', {
number: true,
default: 443,
describe: 'The port to pind the https server to'
})
.option('disableUpdate', {
boolean: true,
default: false,
describe: 'Wheather the server should check for updates'
})
.option('verbose', {
boolean: true,
default: false,
describe: 'Wheather image generation output should be printed'
})
.option('no-images', {
boolean: true,
default: false,
describe: 'Wheather to generate images'
})
.argv;
let data:ProgrammSettingsInterface;
if (fs.existsSync('settings.json'))
data = <ProgrammSettingsInterface> JSON.parse(fs.readFileSync('settings.json').toString());
if (!fs.existsSync('data'))
fs.mkdirSync('data');
if (data !== undefined) {
argv['Video Directory'] = (data['Video Directory'] !== undefined) ? path.resolve(data['Video Directory'].toString()) : false || argv['Video Directory'];
argv['Working Directory'] = (data['Working Directory'] !== undefined) ? path.resolve(data['Working Directory'].toString()) : false || argv['Working Directory'];
argv.sync = data.sync || argv.sync;
argv.debug = data.debug || argv.debug;
argv.disableUpdate = data.disableUpdate || argv.disableUpdate;
argv.verbose = data.verbose || argv.verbose;
argv['no-images'] = data['no-images'] || argv['no-images'];
argv.httpPort = 'httpPort' in data && Number.isInteger(data['httpPort']) ? parseInt(data['httpPort']) : argv.httpPort;
argv.httpsPort = 'httpsPort' in data && Number.isInteger(data['httpsPort']) ? parseInt(data['httpsPort']) : argv.httpsPort;
}
if (argv['Video Directory'])
argv['Video Directory'] = path.isAbsolute(argv['Video Directory']) ? path.resolve(argv['Video Directory']) : path.relative(__dirname, argv['Video Directory']);
export {argv};