Permalink
Browse files

usage info

  • Loading branch information...
1 parent 7889ddf commit cdef9833b3cde0b4690f4b62f89c86ef51bb07f8 @substack committed Jun 13, 2012
Showing with 35 additions and 8 deletions.
  1. +5 −0 bin/cmd.js
  2. +23 −0 bin/usage.txt
  3. +7 −8 index.js
View
5 bin/cmd.js 100644 → 100755
@@ -1,8 +1,13 @@
+#!/usr/bin/env node
var pkginit = require('../');
var fs = require('fs');
var argv = require('optimist').argv;
var cmd = argv._[0];
+if (cmd === 'help' || argv.h || argv.help) {
+ fs.createReadStream(__dirname + '/usage.txt').pipe(process.stdout);
+ return;
+}
pkginit({ context : argv }, function (err, pkg) {
if (err) return console.error(err);
View
@@ -0,0 +1,23 @@
+usage:
+
+ pkginit add [name] [file]
+
+ Store the file at [file] with the name [name].
+
+ pkginit rm [name]
+
+ Remove the file [name] from the registry.
+
+ pkginit list
+
+ List the files in the registry.
+
+ pkginit edit [name]
+
+ Edit the file at [name] with $EDITOR.
+
+ pkginit build [name]
+ pkginit [name]
+
+ Generate a package with the file at [name].
+
View
@@ -78,24 +78,23 @@ PkgInit.prototype.list = function (cb) {
};
PkgInit.prototype.edit = function (name, opts, cb) {
+ if (typeof opts === 'function') {
+ cb = opts;
+ opts = {};
+ }
if (!opts) opts = {};
var editor = opts.editor || process.env.EDITOR || 'vim';
var file = this.filename(name);
- var opts = {
- customFds : [ 0, 1, 2 ],
- env : process.env,
- cwd : process.cwd()
- };
setRaw(true);
- var ps = spawn(editor, [ file ], opts);
+ var ps = spawn(editor, [ file ], { customFds : [ 0, 1, 2 ] });
process.stdin.pipe(ps);
- ps.on('exit', function () {
+ ps.on('exit', function (code, sig) {
setRaw(false);
process.stdin.pause();
- if (cb) cb()
+ if (typeof cb === 'function') cb(code, sig)
});
};

0 comments on commit cdef983

Please sign in to comment.