Skip to content

Commit

Permalink
Added air-drop --help
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisjpowers committed Jul 12, 2012
1 parent 4dc10ef commit 948d299
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 3 deletions.
4 changes: 4 additions & 0 deletions README.md
Expand Up @@ -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)
Expand Down
30 changes: 27 additions & 3 deletions bin/cli.js
Expand Up @@ -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();

Expand Down

0 comments on commit 948d299

Please sign in to comment.