mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 02:35:49 +00:00
fix(cloudcmd) show help and start
This commit is contained in:
parent
06e862ff15
commit
181a22f61d
1 changed files with 18 additions and 17 deletions
|
|
@ -9,27 +9,28 @@
|
|||
DIR_LIB = DIR + 'lib/',
|
||||
|
||||
Util = require(DIR_LIB + 'util'),
|
||||
|
||||
config = {},
|
||||
|
||||
port,
|
||||
argv = process.argv,
|
||||
argvLength = argv.length,
|
||||
argvLast = argv.slice().pop();
|
||||
|
||||
switch (argvLast) {
|
||||
default:
|
||||
if (argvLength > 2)
|
||||
if (isPort(argv)) {
|
||||
if (argvLast - 0 > 0)
|
||||
config.port = argvLast;
|
||||
port = argvLast - 0;
|
||||
|
||||
if (argvLength === 2)
|
||||
start();
|
||||
else
|
||||
if (!isPort(argv))
|
||||
help();
|
||||
else
|
||||
if (isNaN(port))
|
||||
throw('Error: port should be a number.');
|
||||
else
|
||||
console.log('Error: port should be a number.');
|
||||
}
|
||||
else
|
||||
help();
|
||||
|
||||
start(config);
|
||||
|
||||
start({
|
||||
port: port
|
||||
});
|
||||
|
||||
break;
|
||||
|
||||
case '--test':
|
||||
|
|
@ -66,10 +67,10 @@
|
|||
console.log('v' + Info.version);
|
||||
}
|
||||
|
||||
function start(params) {
|
||||
var cloudcmd = require('../cloudcmd');
|
||||
function start(config) {
|
||||
var cloudcmd = require('..');
|
||||
|
||||
cloudcmd.start(params);
|
||||
cloudcmd.start(config);
|
||||
}
|
||||
|
||||
function isPort(argv) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue