celeri icon indicating copy to clipboard operation
celeri copied to clipboard

Exit if the command is passed in.

Open CoderPuppy opened this issue 13 years ago • 6 comments

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();
});

CoderPuppy avatar May 20 '12 11:05 CoderPuppy

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?

crcn avatar May 22 '12 16:05 crcn

Oh, Thanks. The example at the top of the README said you should call celeri.open().

CoderPuppy avatar May 22 '12 16:05 CoderPuppy

Would this work

celeri.parse(process.argv, function(e, cmd) {
    if(e) throw e;

    if(!cmd.command.length) celeri.open();
});

CoderPuppy avatar May 22 '12 16:05 CoderPuppy

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".

CoderPuppy avatar May 22 '12 16:05 CoderPuppy

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.

crcn avatar May 22 '12 16:05 crcn

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

CoderPuppy avatar May 22 '12 18:05 CoderPuppy