mirror of
https://github.com/openstf/stf
synced 2025-10-05 19:42:01 +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:
parent
72a16ed2ff
commit
cc736ba0ac
35 changed files with 2006 additions and 1538 deletions
61
lib/cli/app/index.js
Normal file
61
lib/cli/app/index.js
Normal file
|
@ -0,0 +1,61 @@
|
|||
module.exports.command = 'app'
|
||||
|
||||
module.exports.describe = 'Start an app unit.'
|
||||
|
||||
module.exports.builder = function(yargs) {
|
||||
return yargs
|
||||
.env('STF_APP')
|
||||
.strict()
|
||||
.option('auth-url', {
|
||||
alias: 'a'
|
||||
, describe: 'URL to the auth unit.'
|
||||
, type: 'string'
|
||||
, demand: true
|
||||
})
|
||||
.option('port', {
|
||||
alias: 'p'
|
||||
, describe: 'The port to bind to.'
|
||||
, type: 'number'
|
||||
, default: process.env.PORT || 7105
|
||||
})
|
||||
.option('secret', {
|
||||
alias: 's'
|
||||
, describe: 'The secret to use for auth JSON Web Tokens. Anyone who ' +
|
||||
'knows this token can freely enter the system if they want, so keep ' +
|
||||
'it safe.'
|
||||
, type: 'string'
|
||||
, default: process.env.SECRET
|
||||
, demand: true
|
||||
})
|
||||
.option('ssid', {
|
||||
alias: 'i'
|
||||
, describe: 'The name of the session ID cookie.'
|
||||
, type: 'string'
|
||||
, default: process.env.SSID || 'ssid'
|
||||
})
|
||||
.option('user-profile-url', {
|
||||
describe: 'URL to an external user profile page.'
|
||||
, type: 'string'
|
||||
})
|
||||
.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_APP_` (e.g. ' +
|
||||
'`STF_APP_AUTH_URL`).')
|
||||
}
|
||||
|
||||
module.exports.handler = function(argv) {
|
||||
return require('../../units/app')({
|
||||
port: argv.port
|
||||
, secret: argv.secret
|
||||
, ssid: argv.ssid
|
||||
, authUrl: argv.authUrl
|
||||
, websocketUrl: argv.websocketUrl
|
||||
, userProfileUrl: argv.userProfileUrl
|
||||
})
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue