1
0
Fork 0
mirror of https://github.com/openstf/stf synced 2025-10-03 17:59:28 +02:00

Ported CLI from commander to yargs because yargs suits our large CLI better and is easier to develop with. Split commands into separate files since the file was getting annoyingly long.

This commit is contained in:
Simo Kinnunen 2016-12-21 01:09:08 +09:00
parent 72a16ed2ff
commit cc736ba0ac
35 changed files with 2006 additions and 1538 deletions

50
lib/cli/reaper/index.js Normal file
View file

@ -0,0 +1,50 @@
module.exports.command = 'reaper [name]'
module.exports.describe = 'Start a reaper unit.'
module.exports.builder = function(yargs) {
var os = require('os')
return yargs
.env('STF_REAPER')
.strict()
.option('connect-push', {
alias: 'p'
, describe: 'Device-side ZeroMQ PULL endpoint to connect to.'
, array: true
, demand: true
})
.option('connect-sub', {
alias: 's'
, describe: 'App-side ZeroMQ PUB endpoint to connect to.'
, array: true
, demand: true
})
.option('heartbeat-timeout', {
alias: 't'
, describe: 'Consider devices with heartbeat older than the timeout ' +
'value dead. Given in milliseconds.'
, type: 'number'
, default: 30000
})
.option('name', {
describe: 'An easily identifiable name for log output.'
, type: 'string'
, default: os.hostname()
})
.epilog('Each option can be be overwritten with an environment variable ' +
'by converting the option to uppercase, replacing dashes with ' +
'underscores and prefixing it with `STF_REAPER_` (e.g. ' +
'`STF_REAPER_CONNECT_PUSH`).')
}
module.exports.handler = function(argv) {
return require('../../units/reaper')({
name: argv.name
, heartbeatTimeout: argv.heartbeatTimeout
, endpoints: {
push: argv.connectPush
, sub: argv.connectSub
}
})
}