MXS-1300: Make MaxCtrl more like a library
All invocations into the common helper functions are now done through the `maxctrl` function. This allows the program arguments to be passed to the core as a parameter instead of reading them from global variables. This helps with the implicit initialization that was done when the yargs library was required which caused duplicated output. Refactored the core functions so that they only process the argument vector. The parsing of the argument vector is done in maxctrl.js where it is more appropriate.
This commit is contained in:
@ -10,24 +10,16 @@
|
||||
* of this software will be governed by version 2 or later of the General
|
||||
* Public License.
|
||||
*/
|
||||
require('./common.js')()
|
||||
|
||||
var fs = require('fs')
|
||||
var program = require('yargs');
|
||||
|
||||
const maxctrl_version = '1.0.0';
|
||||
|
||||
require('./common.js')()
|
||||
|
||||
module.exports = function(argv) {
|
||||
|
||||
// Mangle the arguments if we are being called from the command line
|
||||
if (argv[0] == process.execPath) {
|
||||
argv.shift()
|
||||
}
|
||||
|
||||
try {
|
||||
while (argv.length > 0) {
|
||||
fs.accessSync(argv[0])
|
||||
argv.shift()
|
||||
}
|
||||
} catch (err) { }
|
||||
|
||||
return new Promise(function(resolve, reject) {
|
||||
program
|
||||
.version(maxctrl_version)
|
||||
|
Reference in New Issue
Block a user