-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.js
100 lines (97 loc) · 2.43 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
'use strict'
const app = require('./src/app')
const argv = require('yargs')
const logger = require('riverpig')('ecb:index')
function run () {
require('dotenv').config()
argv
.usage('Usage: $0 <command> [options]')
.command({
command: 'configure',
describe: 'Initial configuration for connector-bundle',
builder: {
testnet: {
type: 'boolean',
alias: 't',
default: false,
description: 'Interledger mainnet or testnet'
},
filePath: {
type: 'string',
alias: 'f',
default: './config.json',
description: 'File to store configuration'
},
inquire: {
type: 'boolean',
alias: 'i',
default: 'false',
description: 'Cli prompt (true) or env (false)'
}
},
handler: async (argv) => {
await app.configure(argv.testnet, argv.filePath, argv.inquire).catch(e => {
logger.error(e)
process.exit(1)
})
}
})
.command({
command: 'start',
describe: 'Start connector bundle',
builder: {
filePath: {
type: 'string',
alias: 'f',
default: './config.json',
description: 'File to load connector configuration'
}
},
handler: async (argv) => {
await app.start(argv.filePath).catch(e => {
logger.error(e)
process.exit(1)
})
}
})
.command({
command: 'addAccount',
describe: 'Add account to a running connector',
builder: {
filePath: {
type: 'string',
alias: 'f',
default: './config.json',
description: 'File to append configuration for the connector account'
},
plugin: {
type: 'string',
alias: 'p',
default: 'ilp-plugin-xrp-paychan',
description: 'The type of plugin to use for the connector account'
},
name: {
type: 'string',
alias: 'n',
description: 'The name of the plugin to use for the connector account',
demandOption: true
}
},
handler: async (argv) => {
await app.addAccount(argv).catch(e => {
logger.error(e)
process.exit(1)
})
}
})
.help('h')
.alias('h', 'help')
.argv
}
if (require.main == module) {
run()
}
module.exports = {
app,
run
}