-
Notifications
You must be signed in to change notification settings - Fork 1
/
cli.js
executable file
·41 lines (39 loc) · 1.02 KB
/
cli.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
#!/usr/bin/env node
const yargs = require('yargs')
const fs = require('fs')
const yaml = require('js-yaml')
const replication = require('./lib/cli/replication')
const users = require('./lib/cli/users')
// This seems required to parse
async function main() {
// eslint-disable-next-line no-unused-vars
const { argv } = await yargs
.usage('Usage: $0 -c <configfile>')
// Loads the configuration
.config('f', 'Configuration file', (filename) => {
const file = fs.existsSync(filename) ? filename : 'hydra.yaml'
return yaml.safeLoad(fs.readFileSync(file, 'utf8'))
})
.command(replication)
.command(users)
.demandCommand()
.help()
.fail((msg, err, args) => {
console.error(msg)
console.error('')
console.error(args.help())
console.error('')
if (err) throw err // preserve stack
process.exit(1)
})
// Disable wrapping
.wrap(null)
.epilog('Hail Hydra\ncopyright 2020 unu GmbH')
.argv
}
try {
main()
} catch (e) {
console.log(e)
throw e
}