You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by an...@apache.org on 2013/06/18 01:17:15 UTC

[2/5] git commit: updating cli options and adding short hands

updating cli options and adding short hands


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugman/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugman/commit/7156b0fd
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugman/tree/7156b0fd
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugman/diff/7156b0fd

Branch: refs/heads/plugman-registry
Commit: 7156b0fd7cd151f4b46496f1585af71b91af4cfb
Parents: 79f1488
Author: Anis Kadri <an...@apache.org>
Authored: Mon Jun 17 15:57:52 2013 -0700
Committer: Anis Kadri <an...@apache.org>
Committed: Mon Jun 17 15:57:52 2013 -0700

----------------------------------------------------------------------
 main.js | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/7156b0fd/main.js
----------------------------------------------------------------------
diff --git a/main.js b/main.js
index 77a6725..a3cf53e 100755
--- a/main.js
+++ b/main.js
@@ -37,15 +37,19 @@ var known_opts = { 'platform' : [ 'ios', 'android', 'blackberry10', 'wp7', 'wp8'
             , 'publish' : Boolean 
             , 'unpublish' : Boolean 
             , 'search' : String
-            , 'v' : Boolean
+            , 'version' : Boolean
+            , 'help' : Boolean
             , 'debug' : Boolean
             , 'plugins': path
             , 'link': Boolean
             , 'variable' : Array
             , 'www': path
             }, shortHands = { 'var' : 'variable' };
-
-var cli_opts = nopt(known_opts);
+var short_hands = {
+    "v": ["--version"]
+  , "h": ["--help"]
+}
+var cli_opts = nopt(known_opts, short_hands);
 
 // Default the plugins_dir to './cordova/plugins'.
 var plugins_dir;
@@ -62,8 +66,11 @@ process.on('uncaughtException', function(error){
     process.exit(1);
 });
 
-if (cli_opts.v) {
+if (cli_opts.version) {
     console.log(package.name + ' version ' + package.version);
+} 
+else if (cli_opts.help) {
+  printUsage();
 }
 else if ((cli_opts.install || cli_opts.uninstall || cli_opts.argv.original.length == 0) && (!cli_opts.platform || !cli_opts.project || !cli_opts.plugin)) {
     printUsage();