Skip to content
Browse files

Added air-drop --help

  • Loading branch information...
1 parent 4dc10ef commit 948d2995b6e242ced99d1f49f079efbda0ae49f6 @chrisjpowers committed Jul 12, 2012
Showing with 31 additions and 3 deletions.
  1. +4 −0 README.md
  2. +27 −3 bin/cli.js
View
4 README.md
@@ -419,18 +419,22 @@ AirDrop("/my-package.css")
.package();
```
+For syntax help, use `air-drop --help`.
+
A few notes about the `air-drop` command:
* On the command line, files are always packaged like the `package()`
method is used.
* Caching doesn't make sense on the command line, so there is no
equivalent to the `cache()` method.
* Globs, JS dependencies and CSS dependencies are all supported.
+* Paths are added to the package in the order they are included/required.
* Currently the built-in compilers (CoffeeScript, Less, Stylus)
are supported, but custom compilers are not.
## TODO
+- Add more robust options parsing and error handling in CLI
- Support modules in `$NODE_PATH`, not just `node_modules`
- Integration level tests
- Improve caching mechanism to integrate storage outside of memory (flat files, memcached)
View
30 bin/cli.js
@@ -6,18 +6,42 @@ var token,
AirDrop = require(pathLib.join(__dirname, "..", "lib", "air-drop.js")),
package = require(pathLib.join(__dirname, "..", "package.json"));
-if (process.argv.indexOf("-v") > -1) {
+function hasFlag() {
+ for(var i=0; i < arguments.length; i++) {
+ var flag = arguments[i];
+ if (process.argv.indexOf(flag) > -1) return true;
+ }
+ return false;
+}
+
+if (hasFlag("-v", "--version")) {
console.log(package.version);
process.exit();
}
-if (process.argv.indexOf("--css") > -1) {
+if (hasFlag("-h", "--help")) {
+ var lines = [
+ "Usage: air-drop [options] > my-package.js",
+ "Options:",
+ " --css : Treat the package as a CSS package",
+ " --help, -h : Display this help message",
+ " --include [path] : Includes the path into the package",
+ " --minimize : Minimize the package",
+ " --require [path] : Requires the path into the package",
+ " --strip-function [name] : Remove uses of the named function from the package",
+ " --version, -v : Display the version of air-drop"
+ ];
+ console.log(lines.join("\n"));
+ process.exit();
+}
+
+if (hasFlag("--css")) {
drop = AirDrop("main.css");
} else {
drop = AirDrop("main.js");
}
-if (process.argv.indexOf("--minimize") > -1) drop.minimize();
+if (hasFlag("--minimize")) drop.minimize();
drop.package();

0 comments on commit 948d299

Please sign in to comment.
Something went wrong with that request. Please try again.