Exit if the command is passed in.
If you pass a command in to it like node ./cmd help it currently opens a shell but it seems like it should just exit.
My implementation is call process.exit in the parse callback but asynchronous commands fail then.
celeri.parse(process.argv, function(e, cmd) {
if(e) throw e;
if(cmd.command.length) process.exit();
});
Node should exit if you pass a command into celeri. Make sure you're not calling celeri.open() anywhere in your code - it's basically a wrapper for process.openStdin().
If you're not calling celeri.open(), do you have an example where this possible bug is occurring?
Oh, Thanks.
The example at the top of the README said you should call celeri.open().
Would this work
celeri.parse(process.argv, function(e, cmd) {
if(e) throw e;
if(!cmd.command.length) celeri.open();
});
It doesn't work. What should I run to get it to run a command that was passed in but if one is not passed in open the "shell".
I'd approach it a different way. Instead, perhaps create an interactive command. For example:
var celeri = require("celeri");
celeri.onCommand("interact", function(data)
{
celeri.open();
});
celeri.parse(process.argv);
In terminal, you can call:
node ./cmd interact
to make your app interactive.
Thanks, Sounds good.
But I'm having a different problem now.
I start it node bin/jules.js interact but It just hangs saying:
tty.setRawMode is deprecated. Use `process.stdin.setRawMode()` instead.
When I debugged it it just never got any keystrokes (I did press keys). On node 0.7.7 compiled from source on Ubuntu 11.04 32-bit