forked from BaoXuebin/beancount-node-server
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
37 lines (31 loc) · 1.08 KB
/
script.js
File metadata and controls
37 lines (31 loc) · 1.08 KB
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
#!/usr/bin/env node
const { Command } = require('commander');
const BeancountNsApp = require('./app');
const PackageInfo = require('./package.json')
const Config = require('./config/config.json')
const port = 3001
const program = new Command();
// options
program
.version(PackageInfo.version, '-v, --version')
.option('-p, --port [type]', `beancount-ns port [${port}]`)
.option('-dp, --dataPath [type]', `config dataPath [${Config.dataPath}]`)
.option('-c, --operatingCurrency [type]', `config operatingCurrency [${Config.operatingCurrency}]`)
.option('-d, --startDate [type]', `config startDate [${Config.startDate}]`)
.option('-b, --isBak [type]', `config isBak [${Config.isBak}]`)
.parse(process.argv);
// npm script
program
.command('start')
.description('start beancount-ns');
program
.command('config')
.description('show default config')
.action(() => {
console.log(JSON.stringify(Config))
});
const options = program.opts();
if (options.isBak) {
options.isBak = JSON.parse(options.isBak)
}
BeancountNsApp(Object.assign(Config, options), options.port || port)