mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 18:55:26 +00:00
feature(bin) add --username, --password, --save
This commit is contained in:
parent
d775b6d736
commit
2cfacf60c0
3 changed files with 54 additions and 19 deletions
5
HELP.md
5
HELP.md
|
|
@ -60,7 +60,10 @@ Cloud Commander supports command line parameters:
|
|||
|:----------------------|:--------------------------------------------
|
||||
| `-h, --help` | display help and exit
|
||||
| `-v, --version` | output version information and exit
|
||||
| `-p, --port` | set port number and start
|
||||
| `-s, --save` | save options
|
||||
| `-p, --port` | set port number
|
||||
| `-u, --username` | set username
|
||||
| `-ps, --password` | set password
|
||||
|
||||
If no parameters given Cloud Commander reads information from `~/.cloudcmd.json` and use
|
||||
port from it (`8000` default). if port variables `PORT` or `VCAP_APP_PORT` isn't exist.
|
||||
|
|
|
|||
|
|
@ -3,23 +3,29 @@
|
|||
(function() {
|
||||
'use strict';
|
||||
|
||||
var Info = require('../package'),
|
||||
var config,
|
||||
Info = require('../package'),
|
||||
|
||||
DIR = __dirname + '/../',
|
||||
DIR_LIB = DIR + 'lib/',
|
||||
DIR_SERVER = DIR_LIB + 'server/',
|
||||
|
||||
rendy = require('rendy'),
|
||||
createPass = require(DIR_SERVER + 'password'),
|
||||
|
||||
HOME_PAGE = 'General help using Cloud Commander: <{{ url }}>',
|
||||
|
||||
argv = process.argv,
|
||||
args = require('minimist')(argv.slice(2), {
|
||||
string: 'port',
|
||||
boolean: ['test', 'repl'],
|
||||
string: ['port', 'password', 'username'],
|
||||
boolean: ['test', 'repl', 'save'],
|
||||
alias: {
|
||||
v: 'version',
|
||||
h: 'help',
|
||||
p: 'port'
|
||||
p: 'port',
|
||||
u: 'username',
|
||||
ps: 'password',
|
||||
s: 'save'
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -29,22 +35,20 @@
|
|||
help();
|
||||
} else if (args.test) {
|
||||
test();
|
||||
} else if (!args.repl && !args.port) {
|
||||
start();
|
||||
} else {
|
||||
if (args.repl)
|
||||
repl();
|
||||
|
||||
if (!args.port)
|
||||
start();
|
||||
config = require(DIR_SERVER + 'config');
|
||||
|
||||
password(args.password);
|
||||
username(args.username);
|
||||
port(args.port);
|
||||
|
||||
if (args.save)
|
||||
config.save(start);
|
||||
else
|
||||
if (isNaN(args.port))
|
||||
console.error('Error: port should be a number!');
|
||||
else
|
||||
start({
|
||||
port: args.port
|
||||
});
|
||||
|
||||
start();
|
||||
}
|
||||
|
||||
function test() {
|
||||
|
|
@ -64,6 +68,31 @@
|
|||
require(SERVER)(config);
|
||||
}
|
||||
|
||||
function password(pass) {
|
||||
var algo, hash;
|
||||
|
||||
if (pass) {
|
||||
algo = config('algo');
|
||||
hash = createPass(algo, pass);
|
||||
|
||||
config('password', hash);
|
||||
}
|
||||
}
|
||||
|
||||
function username(name) {
|
||||
if (name)
|
||||
config('username', name);
|
||||
}
|
||||
|
||||
function port(number) {
|
||||
if (port) {
|
||||
if (!isNaN(number))
|
||||
config('port', number);
|
||||
else
|
||||
console.error('port: ignored, should be a number');
|
||||
}
|
||||
}
|
||||
|
||||
function help() {
|
||||
var bin = require('../json/bin'),
|
||||
usage = 'Usage: cloudcmd [options]',
|
||||
|
|
|
|||
|
|
@ -1,5 +1,8 @@
|
|||
{
|
||||
"-h, --help ": "display this help and exit",
|
||||
"-v, --version ": "output version information and exit",
|
||||
"-p, --port ": "set port number and start"
|
||||
"-h, --help " : "display this help and exit",
|
||||
"-v, --version " : "output version information and exit",
|
||||
"-s, --save " : "save options",
|
||||
"-p, --port " : "set port number",
|
||||
"-u, --username " : "set username",
|
||||
"-ps, --password" : "set password"
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue