mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 02:35:49 +00:00
feature(cloudcmd) add -h, --help
This commit is contained in:
parent
ffdf5ec12f
commit
67b4a689ff
2 changed files with 43 additions and 6 deletions
|
|
@ -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
5
json/bin.json
Normal 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"
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue