1
0
Fork 0
mirror of https://github.com/openstf/stf synced 2025-10-05 02:29:26 +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

70
lib/cli/poorxy/index.js Normal file
View file

@ -0,0 +1,70 @@
module.exports.command = 'poorxy'
module.exports.builder = function(yargs) {
return yargs
.strict()
.env('STF_POORXY')
.option('api-url', {
alias: 'i'
, describe: 'URL to the api unit.'
, type: 'string'
, demand: true
})
.option('app-url', {
alias: 'u'
, describe: 'URL to the app unit.'
, type: 'string'
, demand: true
})
.option('auth-url', {
alias: 'a'
, describe: 'URL to the auth unit.'
, type: 'string'
, demand: true
})
.option('port', {
alias: 'p'
, describe: 'The port to launch poorxy on.'
, type: 'number'
, default: process.env.PORT || 7100
})
.option('storage-plugin-apk-url', {
describe: 'URL to the APK storage plugin unit.'
, type: 'string'
, demand: true
})
.option('storage-plugin-image-url', {
describe: 'URL to the image storage plugin unit.'
, type: 'string'
, demand: true
})
.option('storage-url', {
alias: 'r'
, describe: 'URL to the storage unit.'
, type: 'string'
, demand: true
})
.option('websocket-url', {
alias: 'w'
, describe: 'URL to the websocket unit.'
, type: 'string'
, demand: true
})
.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_POORXY_` (e.g. ' +
'`STF_POORXY_PORT`).')
}
module.exports.handler = function(argv) {
return require('../../units/poorxy')({
port: argv.port
, appUrl: argv.appUrl
, apiUrl: argv.apiUrl
, authUrl: argv.authUrl
, websocketUrl: argv.websocketUrl
, storageUrl: argv.storageUrl
, storagePluginImageUrl: argv.storagePluginImageUrl
, storagePluginApkUrl: argv.storagePluginApkUrl
})
}