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:
parent
72a16ed2ff
commit
cc736ba0ac
35 changed files with 2006 additions and 1538 deletions
48
lib/cli/storage-plugin-image/index.js
Normal file
48
lib/cli/storage-plugin-image/index.js
Normal file
|
@ -0,0 +1,48 @@
|
|||
module.exports.command = 'storage-plugin-image'
|
||||
|
||||
module.exports.describe = 'Start an image storage plugin unit.'
|
||||
|
||||
module.exports.builder = function(yargs) {
|
||||
var os = require('os')
|
||||
|
||||
return yargs
|
||||
.env('STF_STORAGE_PLUGIN_IMAGE')
|
||||
.strict()
|
||||
.option('concurrency', {
|
||||
alias: 'c'
|
||||
, describe: 'Maximum number of simultaneous transformations.'
|
||||
, type: 'number'
|
||||
})
|
||||
.option('port', {
|
||||
alias: 'p'
|
||||
, describe: 'The port to bind to.'
|
||||
, type: 'number'
|
||||
, default: process.env.PORT || 7100
|
||||
})
|
||||
.option('storage-url', {
|
||||
alias: 'r'
|
||||
, describe: 'URL to the storage unit.'
|
||||
, type: 'string'
|
||||
, demand: true
|
||||
})
|
||||
.option('cache-dir', {
|
||||
describe: 'The location where to cache images.'
|
||||
, type: 'string'
|
||||
, default: os.tmpdir()
|
||||
})
|
||||
.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_STORAGE_PLUGIN_IMAGE_` (e.g. ' +
|
||||
'`STF_STORAGE_PLUGIN_IMAGE_CONCURRENCY`).')
|
||||
}
|
||||
|
||||
module.exports.handler = function(argv) {
|
||||
var os = require('os')
|
||||
|
||||
return require('../../units/storage/plugins/image')({
|
||||
port: argv.port
|
||||
, storageUrl: argv.storageUrl
|
||||
, cacheDir: argv.cacheDir
|
||||
, concurrency: argv.concurrency || os.cpus().length
|
||||
})
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue