You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ripple.apache.org by ti...@apache.org on 2015/07/15 03:19:14 UTC
[2/3] incubator-ripple git commit: Validate command-line options.
Validate command-line options.
Some shallow validation of the command-line options. It is needed for
the emulate logic to be able to assume that options.<opt> name has the
right amount of elements. The validation is added for 'emulate' command
only so far.
Project: http://git-wip-us.apache.org/repos/asf/incubator-ripple/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ripple/commit/5fcf93a5
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ripple/tree/5fcf93a5
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ripple/diff/5fcf93a5
Branch: refs/heads/master
Commit: 5fcf93a50ff8eaea96ca8734f2ecb1259b48b5f3
Parents: adc76f2
Author: Arzhan Kinzhalin <ar...@intel.com>
Authored: Tue Jun 30 19:52:02 2015 -0300
Committer: Tim Barham <ti...@microsoft.com>
Committed: Wed Jul 15 10:49:25 2015 +1000
----------------------------------------------------------------------
lib/cli/emulate.js | 28 ++++++++++++++++++++++++++--
1 file changed, 26 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ripple/blob/5fcf93a5/lib/cli/emulate.js
----------------------------------------------------------------------
diff --git a/lib/cli/emulate.js b/lib/cli/emulate.js
index 8648b6e..bfa6b77 100644
--- a/lib/cli/emulate.js
+++ b/lib/cli/emulate.js
@@ -20,11 +20,35 @@
*/
var self,
open = require('open'),
- emulate = require('./../server/emulate');
+ emulate = require('./../server/emulate'),
+ help = require('./help'),
+ colors = require('colors');
+
+colors.mode = "console";
self = {
call: function (opts) {
- self.start(opts);
+ if (self.validateOptions(opts)) {
+ self.start(opts);
+ } else {
+ console.error(('Options not understood: ' + process.argv.splice(2).join(' ')).red.bold);
+ help.call('emulate');
+ }
+ },
+ validateOptions: function (opts) {
+ if (opts.path && opts.path.length !== 1) {
+ return false;
+ }
+ if (opts.port && opts.port.length !== 1) {
+ return false;
+ }
+ if (opts.remote && opts.remote.length !== 1) {
+ return false;
+ }
+ if (opts.route && opts.route.length !== 1) {
+ return false;
+ }
+ return true;
},
start: function (opts) {
var app = emulate.start(opts);