You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by js...@apache.org on 2014/07/29 22:08:59 UTC

[2/2] git commit: CB-7220 Split cordova help into per feature help files

CB-7220 Split cordova help into per feature help files


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

Branch: refs/heads/master
Commit: b47f75b2fadff254726329eac962a0095c065811
Parents: 472aaac
Author: Josh Soref <js...@blackberry.com>
Authored: Tue Jul 29 14:16:46 2014 -0400
Committer: Josh Soref <js...@blackberry.com>
Committed: Tue Jul 29 15:05:36 2014 -0400

----------------------------------------------------------------------
 doc/build.txt    |  7 +++++
 doc/compile.txt  |  5 ++++
 doc/cordova.txt  | 37 +++++++++++++++++++++++
 doc/create.txt   | 16 ++++++++++
 doc/emulate.txt  |  6 ++++
 doc/help.txt     | 82 +++------------------------------------------------
 doc/info.txt     |  7 +++++
 doc/platform.txt | 17 +++++++++++
 doc/plugin.txt   | 21 +++++++++++++
 doc/prepare.txt  |  7 +++++
 doc/restore.txt  | 10 +++++++
 doc/run.txt      | 15 ++++++++++
 doc/save.txt     | 12 ++++++++
 doc/serve.txt    |  8 +++++
 src/cli.js       |  5 +++-
 src/help.js      | 25 ++++++++++++++--
 16 files changed, 199 insertions(+), 81 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/b47f75b2/doc/build.txt
----------------------------------------------------------------------
diff --git a/doc/build.txt b/doc/build.txt
new file mode 100644
index 0000000..69281be
--- /dev/null
+++ b/doc/build.txt
@@ -0,0 +1,7 @@
+Synopsis
+
+    cordova build [PLATFORM..]
+
+Shortcut for `cordova prepare` + `cordova compile` for
+all/the specified platforms.
+

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/b47f75b2/doc/compile.txt
----------------------------------------------------------------------
diff --git a/doc/compile.txt b/doc/compile.txt
new file mode 100644
index 0000000..343dffa
--- /dev/null
+++ b/doc/compile.txt
@@ -0,0 +1,5 @@
+Synopsis
+
+    cordova compile [PLATFORM..]
+
+Builds the app for specified platforms, or all platforms

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/b47f75b2/doc/cordova.txt
----------------------------------------------------------------------
diff --git a/doc/cordova.txt b/doc/cordova.txt
new file mode 100644
index 0000000..e2e9da3
--- /dev/null
+++ b/doc/cordova.txt
@@ -0,0 +1,37 @@
+Synopsis
+
+    cordova command [options]
+
+Global Commands
+
+    create ............................. Create a project
+    help ............................... Get help for a command
+
+Project Commands
+
+    info ............................... Generate project information
+
+    platform ........................... Manage project platforms
+    plugin ............................. Manage project plugins
+
+    prepare ............................ Copy files into platform(s) for building
+    compile ............................ Build platform(s)
+    build .............................. prepare + compile
+
+    run ................................ Run project
+    emulate ............................ Run project with an emulator
+    serve .............................. Run project with a local webserver
+
+Experimental Commands
+
+    These commands require the --experimental flag.
+
+    save ............................... Save installed platforms/plugins
+    restore ............................ Restore saved platforms/plugins
+
+Command-line Flags/Options
+
+    -v, --version ...................... prints out this utility's version
+    -d, --verbose ...................... debug mode produces verbose log output for all activity,
+                                         including output of sub-commands cordova invokes
+

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/b47f75b2/doc/create.txt
----------------------------------------------------------------------
diff --git a/doc/create.txt b/doc/create.txt
new file mode 100644
index 0000000..13e2963
--- /dev/null
+++ b/doc/create.txt
@@ -0,0 +1,16 @@
+Synopsis
+
+    cordova create <PATH> [ID [NAME [CONFIG]]] [options] [PLATFORM...]
+
+Create a Cordova project
+
+    PATH ......................... Where to create the project
+    ID ........................... reverse-domain-style package name - used in <widget id>
+    NAME ......................... human readable field
+    CONFIG ....................... json string whose key/values will be included in
+                                    [PATH]/.cordova/config.json
+
+    Options:
+        --copy-from|src=<PATH> ... use custom www assets instead of the stock Cordova hello-world.
+        --link-to=<PATH> ......... symlink to custom www assets without creating a copy.
+

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/b47f75b2/doc/emulate.txt
----------------------------------------------------------------------
diff --git a/doc/emulate.txt b/doc/emulate.txt
new file mode 100644
index 0000000..57408f8
--- /dev/null
+++ b/doc/emulate.txt
@@ -0,0 +1,6 @@
+Synopsis
+
+    cordova emulate [PLATFORM...]
+
+Alias for "run --emulator"
+

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/b47f75b2/doc/help.txt
----------------------------------------------------------------------
diff --git a/doc/help.txt b/doc/help.txt
index c169b6c..b3194ad 100644
--- a/doc/help.txt
+++ b/doc/help.txt
@@ -1,81 +1,7 @@
 Synopsis
 
-    cordova command [options]
-
-Global Commands
-
-    create <PATH> [ID [NAME [CONFIG]]] ....... creates a Cordova project in the specified PATH, with
-                                               ID reverse-domain-style package name - used in <widget id>
-                                               NAME is a human readable field
-                                               CONFIG is a json string whose key/values will be included
-                                               in [PATH]/.cordova/config.json
-                  [--copy-from|src=<PATH>] ... use custom www assets instead of the stock Cordova hello-world.
-                  [--link-to=<PATH>] ......... symlink to custom www assets without creating a copy.
-
-    help ..................................... shows this syntax summary
-
-    info ..................................... print out useful information helpful for submitting bug
-                                               reports and getting help.  Creates an info.txt file at the
-                                               base of your project
-
-Project-Level Commands
-
-    platform(s) [{add|remove|rm} <PLATFORM>] .. add or remove a specified PLATFORM, OR
-                [{list|ls}] ................... list all installed and available platforms
-                [{update|up} <PLATFORM>] ...... update the version of Cordova used for a specific
-                                                PLATFORM; use after updating the CLI.
-                [check] ....................... list platforms which can be updated by `platform update`
-
-    plugin add <SPEC1> [<SPEC2> ...] .......... SPEC can be a plugin ID, a local path, or a git URL.
-               [--searchpath <directory>] ..... When looking up plugins by ID, look in this directory and
-                                                each of its subdirectories for the plugin before hitting the registry.
-                                                Multiple search paths can be used by either specifying the flag multiple
-                                                times, or by separating paths with a delimiter (: on 'nix, ; on Windows).
-
-    plugin(s) rm <plugin_id1> [<plugin_id2>] .. remove a plugin with the given IDs.
-
-              [{ls|list}] ..................... list all currently installed plugins
-              [search <keyword1 keyword2...>] . search the plugin registry for plugins matching the keywords
-
-    prepare [PLATFORM..] ...................... copies files for specified platforms, or all platforms,
-                                                so that the project is ready to build in each SDK
-
-    compile [PLATFORM..] ...................... builds the app for specified platforms, or all platforms
-
-    build [PLATFORM...] ....................... shortcut for prepare, then compile
-
-    run [--debug|--release]
-        [--device|--emulator|--target=FOO]
-        [PLATFORM] ............................ deploys app on specified platform devices / emulators
-
-    emulate [PLATFORM...] ..................... alias for "run --emulator"
-
-    serve [PORT] .............................. runs a local web server for www/ assets. Port defaults to 8000.
-                                                Access projects at: http://HOST_IP:PORT/PLATFORM/www
-
-Experimental Commands
-
-    These commands require the --experimental flag.
-
-    save plugins .............................. save the list of currently installed plugins to config.xml
-         platforms ............................ save the list of currently installed platforms to config.xml
-         [--shrinkwrap] ....................... lock down plugin versions to currently installed versions
-
-    restore plugins ........................... install all plugins that are currently listed in config.xml
-            platforms ......................... install all platforms that are currently listed in config.xml
-
-
-Command-line Flags/Options
-
-    -v, --version ............................. prints out this utility's version
-    -d, --verbose ............................. debug mode produces verbose log output for all activity,
-                                                including output of sub-commands cordova invokes
-
-Example usage
-
-    $ cordova create Baz
-    $ cd Baz
-    $ cordova platform add android
-    $ cordova build
-    $ cordova serve android
+    cordova help [command]
+    cordova [command] -h
+    cordova -h [command]
 
+Show syntax summary, or the help for a specific command.

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/b47f75b2/doc/info.txt
----------------------------------------------------------------------
diff --git a/doc/info.txt b/doc/info.txt
new file mode 100644
index 0000000..0909b7f
--- /dev/null
+++ b/doc/info.txt
@@ -0,0 +1,7 @@
+Synopsis
+
+    cordova info
+
+Print out useful information helpful for submitting bug
+reports and getting help.  Creates an info.txt file at the
+base of your project.

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/b47f75b2/doc/platform.txt
----------------------------------------------------------------------
diff --git a/doc/platform.txt b/doc/platform.txt
new file mode 100644
index 0000000..ef14247
--- /dev/null
+++ b/doc/platform.txt
@@ -0,0 +1,17 @@
+Synopsis
+
+    cordova platform <command> [PLATFORM]
+
+Manage project platforms
+
+    add .................... add specified PLATFORM
+    remove ................. remove specified PLATFORM
+    list ................... list all installed and available platforms
+    update ................. update the version of Cordova used for a specific
+                             PLATFORM; use after updating the CLI.
+    check .................. list platforms which can be updated by `cordova platform update`
+
+aliases:
+    platforms -> platform
+    rm -> remove
+    ls -> list

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/b47f75b2/doc/plugin.txt
----------------------------------------------------------------------
diff --git a/doc/plugin.txt b/doc/plugin.txt
new file mode 100644
index 0000000..c01780c
--- /dev/null
+++ b/doc/plugin.txt
@@ -0,0 +1,21 @@
+Synopsis
+
+    cordova plugin <command> [PLUGIN]
+
+Manage project plugins
+
+    add <SPEC1> [<SPEC2> ...] ............. SPEC can be a plugin ID, a local path, or a git URL.
+        [--searchpath <directory>] ........ When looking up plugins by ID, look in this directory and
+                                            each of its subdirectories for the plugin before hitting the registry.
+                                            Multiple search paths can be used by either specifying the flag multiple
+                                            times, or by separating paths with a delimiter (: on 'nix, ; on Windows).
+
+    remove <plugin_id1> [<plugin_id2>] .... remove plugins with the given IDs.
+
+    list .................................. list currently installed plugins
+    search [<keyword>]* ................... search the plugin registry for plugins matching the keywords
+
+aliases:
+    plugins -> plugin
+    rm -> remove
+    ls -> list

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/b47f75b2/doc/prepare.txt
----------------------------------------------------------------------
diff --git a/doc/prepare.txt b/doc/prepare.txt
new file mode 100644
index 0000000..6ce5123
--- /dev/null
+++ b/doc/prepare.txt
@@ -0,0 +1,7 @@
+Synopsis
+
+    cordova prepare [PLATFORM..]
+
+Copies files for specified platforms, or all platforms,
+so that the project is ready to build with each SDK
+

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/b47f75b2/doc/restore.txt
----------------------------------------------------------------------
diff --git a/doc/restore.txt b/doc/restore.txt
new file mode 100644
index 0000000..c0daeae
--- /dev/null
+++ b/doc/restore.txt
@@ -0,0 +1,10 @@
+Synopsis
+
+    cordova restore <command>
+
+Restore project based on to config.xml
+
+    plugins ........................... install all plugins that are currently listed in config.xml
+    platforms ......................... install all platforms that are currently listed in config.xml
+
+See also: cordova save

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/b47f75b2/doc/run.txt
----------------------------------------------------------------------
diff --git a/doc/run.txt b/doc/run.txt
new file mode 100644
index 0000000..257f227
--- /dev/null
+++ b/doc/run.txt
@@ -0,0 +1,15 @@
+Synopsis
+
+    cordova run [--debug|--release] [--device|--emulator|--target=FOO] [PLATFORM] -- [platformopts]
+
+Deploys app on specified platform devices / emulators
+
+    --debug ............................ Deploy a debug build
+    --release .......................... Deploy a release build
+
+    --device ........................... Deploy to a device
+    --emulator ......................... Deploy to an emulator
+    --target ........................... Deploy to a specific target
+
+To provide platform specific options, you must include them after `--`.
+

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/b47f75b2/doc/save.txt
----------------------------------------------------------------------
diff --git a/doc/save.txt b/doc/save.txt
new file mode 100644
index 0000000..c7c00aa
--- /dev/null
+++ b/doc/save.txt
@@ -0,0 +1,12 @@
+Synopsis
+
+    cordova save <command> [--shrinkwrap]
+
+Save project metadata to config.xml
+
+    platforms ............................ save the list of currently installed platforms to config.xml
+
+    plugins .............................. save the list of currently installed plugins to config.xml
+        [--shrinkwrap] ................... lock down plugin versions to currently installed versions
+
+See also: cordova restore

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/b47f75b2/doc/serve.txt
----------------------------------------------------------------------
diff --git a/doc/serve.txt b/doc/serve.txt
new file mode 100644
index 0000000..38f1af5
--- /dev/null
+++ b/doc/serve.txt
@@ -0,0 +1,8 @@
+Synopsis
+
+    cordova serve [PORT]
+
+Run a local web server for www/ assets. Port defaults to 8000.
+
+Access projects at: http://HOST_IP:PORT/PLATFORM/www
+

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/b47f75b2/src/cli.js
----------------------------------------------------------------------
diff --git a/src/cli.js b/src/cli.js
index 7bf0ec0..2e2d7dd 100644
--- a/src/cli.js
+++ b/src/cli.js
@@ -140,7 +140,10 @@ function cli(inputArgs) {
     var known_platforms = Object.keys(cordova_lib.cordova_platforms);
 
     if ( !cmd || cmd == 'help' || args.help ) {
-        return help();
+        if (!args.help && remain[0] == 'help') {
+            remain.shift();
+        }
+        return help(remain);
     }
 
     if ( !cordova.hasOwnProperty(cmd) ) {

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/b47f75b2/src/help.js
----------------------------------------------------------------------
diff --git a/src/help.js b/src/help.js
index 45d400c..4ac0a4b 100644
--- a/src/help.js
+++ b/src/help.js
@@ -22,8 +22,29 @@ var fs = require('fs'),
     Q = require('q'),
     path = require('path');
 
-module.exports = function help () {
-    var raw = fs.readFileSync(path.join(__dirname, '..', 'doc', 'help.txt')).toString('utf8');
+module.exports = function help (args) {
+    var command,
+        file,
+        raw,
+        docdir;
+    args = args || [];
+    command = ((args)[0] || 'cordova');
+    docdir = path.join(__dirname, '..', 'doc');
+    file = [
+      command + '.md',
+      command + '.txt',
+      'cordova.md',
+      'cordova.txt',
+    ].map(function (file) {
+        var f = path.join(docdir, file);
+        if (fs.existsSync(f)) {
+           return f;
+        }
+        return null;
+    }).filter(function (f) {
+        return f !== null;
+    });
+    raw = fs.readFileSync(file[0]).toString('utf8');
     cordova.emit('results', raw);
     return Q();
 };