-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathrun.js
60 lines (56 loc) · 1.49 KB
/
run.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
const nconf = require('nconf')
const itauscraper = require('./itauscraper.js')
const argv = require('yargs')
.env()
.usage('Usage: node $0 [options]')
.option('branch', {
alias: 'b',
describe: 'Itaú branch number, format: 0000',
required: true,
type: 'string'
})
.option('account', {
alias: 'c',
describe: 'Itaú account number, format: 00000-0',
required: true,
type: 'string'
})
.option('password', {
alias: 'p',
describe: 'Itaú account digital password(6 digits)',
required: true,
type: 'number'
})
.option('name', {
alias: 'n',
describe: 'Itaú account holder name, format: Joao',
type: 'string'
})
.option('days', {
alias: 'd',
describe: 'Transaction log days',
required: true,
type: 'number',
choices: [3, 5, 7, 15, 30, 60, 90]
})
.option('file_format', {
alias: 'f',
describe: 'File format to export',
default: 'txt',
choices: ['pdf', 'txt', 'ofx', 'ofc10', 'ofc106', 'ofc106quicken']
})
.option('node_env', {
describe: 'Node environment',
default: 'production',
choices: ['development', 'production', 'docker']
})
// Config
nconf.env({ lowerCase: true }).argv(argv)
const environment = nconf.get('node_env')
console.log(environment)
nconf.file(environment, './config/' + environment.toLowerCase() + '.json')
nconf.file('default', './config/default.json')
const options = nconf.get()
console.log('Starting using node environment: ' + environment)
// Run
itauscraper(options)