-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
66 lines (61 loc) · 1.9 KB
/
index.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
55
56
57
58
59
60
61
62
63
64
65
66
//@flow
const path = require('path');
const MintwiseController = require('./app/MintSplitwiseController');
const MintwiseCliView = require('./app/MintwiseCliView');
const userIO = require('./lib/userIO');
const logfile = path.join(__dirname, 'log', `log.log`);
const castToBoolean = (val) => !!val;
const argv = require('yargs')
.options({
'offline': {
description: 'use cached version of categories',
type: 'boolean',
conflicts: 'save',
coerce: castToBoolean,
},
'n': {
alias: 'dry-run',
type: 'boolean',
description: 'do not save split selections to SplitWise',
coerce: castToBoolean,
},
'c': {
alias: 'config',
config: true,
default: 'config.json'
},
'f': {
alias: 'file',
type: 'string',
description: 'path to Mint CSV export to split\nif absent, transactions are pulled from mint.com'
},
'd': {
alias: 'debug',
type: 'boolean',
description: `print debug information to terminal\nnote: same information is always logged in log file`
}
})
.help('h')
.alias('h', 'help')
.parse();
const options = {
offline: argv.offline,
save: !argv['dry-run'],
exportFile: argv.file,
splitwiseConsumerKey: argv.splitwiseConsumerKey,
splitwiseConsumerSecret: argv.splitwiseConsumerSecret,
splitwiseGroupId: argv.splitwiseGroupId,
splitwisePayerId: argv.splitwisePayerId,
splitwiseBorrowerId: argv.splitwiseBorrowerId,
mintUsername: argv.mintUsername,
mintPassword: argv.mintPassword,
startDate: argv.startDate,
endDate: argv.endDate,
canadianAccounts: argv.canadianAccounts,
myDefaultShare: argv.myDefaultShare
};
userIO.init({logfile, printLogsOnScreen: argv.debug});
userIO.log('argv:', options);
const view = new MintwiseCliView({print: userIO.print, log: userIO.log});
const controller = new MintwiseController({...options, view: view, log: userIO.log});
controller.init();