Skip to content

Loading…

Exit if the command is passed in. #30

Open
CoderPuppy opened this Issue · 6 comments

2 participants

@CoderPuppy

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

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?

@CoderPuppy

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

@CoderPuppy

Would this work

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

    if(!cmd.command.length) celeri.open();
});
@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".

@crcn

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.

@CoderPuppy

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.