feature(cloudcmd) add -h, --help

This commit is contained in:
coderaiser 2014-07-22 06:53:24 -04:00
parent ffdf5ec12f
commit 67b4a689ff
2 changed files with 43 additions and 6 deletions

View file

@ -13,16 +13,20 @@
config = {},
argv = process.argv,
argvLength = argv.length,
argvLast = argv.slice().pop();
switch (argvLast) {
default:
if (isPort(argv)) {
if (argvLast - 0 > 0)
config.port = argvLast;
else
console.log('Error: port should be a number.');
}
if (argvLength > 2)
if (isPort(argv)) {
if (argvLast - 0 > 0)
config.port = argvLast;
else
console.log('Error: port should be a number.');
}
else
help();
start(config);
@ -44,6 +48,14 @@
case '--version':
version();
break;
case '-h':
help();
break;
case '--help':
help();
break;
}
function version() {
@ -68,4 +80,24 @@
return is;
}
function help() {
var bin = require('../json/bin'),
usage = 'Usage: cloudcmd [OPTION]...',
description = Info.description + '.',
site = Util.render('General help using Cloud Commander: <{{ url }}>', {
url: Info.homepage
});
console.log(usage);
console.log(description + '\n');
Object.keys(bin).forEach(function(name) {
var line = ' ' + name + ' ' + bin[name];
console.log(line);
});
console.log('\n' + site);
}
})();

5
json/bin.json Normal file
View file

@ -0,0 +1,5 @@
{
"-h, --help ": "display this help and exit",
"-v, --version ":"output version information and exit",
"-p, --port ": "set port number and start"
}