dthree / vorpal

Node's framework for interactive CLIs
http://vorpal.js.org
MIT License
5.64k stars 280 forks source link

Feature request: Control+C once breaks input, Control+C twice ends session #25

Closed scotthovestadt closed 8 years ago

scotthovestadt commented 9 years ago

It's feel natural, like you're in a terminal. People are going to expect it to work this way (like the NodeJS shell).

dthree commented 9 years ago

Haha - someone filed the behavior you're requesting as a bug, so I changed it from the default.

I have a method called vorpal.sigint(function() { }), where you can make sigint do whatever you want. Is this fine?


Yikes - I guess I didn't document that...

dthree commented 9 years ago

I'm actually going to do more mature things - I'm going to add functionality to break a current command with control+c, which will optionally fire a method (like command.sigint or command.break), and cut execution of that command.

What do you think?

Shakyamuni177te commented 9 years ago

Makes total sense to me. Just tested and it does feel odd to drop the delimiter after a single ctrl-c. Should require a double-tap.

scotthovestadt commented 9 years ago

Yeah, adding a listener so people can exit if they feel like it works for me.

Shakyamuni177te commented 9 years ago

Does Ctrl-C not end the command for you? It does for me.

Shakyamuni177te commented 9 years ago

Single Ctrl + C:

test

dthree commented 9 years ago

I'm okay with a double-tap by default - but what should the first tap do? I could do something like:

(^C again to quit)

How does that sound?

Shakyamuni177te commented 9 years ago

First tap should quit back to the delimiter. Second tap should exit to shell/command prompt.

Shakyamuni177te commented 9 years ago

So to start with you'd quit out of whatever you're doing and it would come up with, like, myapp$. The second tap it should quit you out of Vorpal entirely.

dthree commented 9 years ago

and if you're already on the delimiter..

Shakyamuni177te commented 9 years ago

Yeah, but I mean if a process is running. It should quit out of the process. Then, if you're on the delimiter it should quit back to shell. Does that make sense?

dthree commented 9 years ago

Yeah. Okay cool.

Shakyamuni177te commented 9 years ago

Sorry, I'd help if I could but I haven't had the experience with the code-base you have. I'll keep playing with it and experimenting with it, don't worry :). :8ball:

dthree commented 9 years ago

Haha no probs :)

scotthovestadt commented 9 years ago

I think it should mimic the NodeJS shell by default. One ctrl+c should automatically break whatever command you're typing if you have anything typed. If your command string is empty, it should say (^C again to quit) and then a second ctrl+c should exit.

dthree commented 9 years ago

Deal.

dthree commented 8 years ago

Done :smiley: