vorpal icon indicating copy to clipboard operation
vorpal copied to clipboard

Exit on parse

Open alansouzati opened this issue 9 years ago • 27 comments

This PR aims to exit (detach the UI) after parser execution is complete.

alansouzati avatar Aug 03 '16 06:08 alansouzati

Not sure this is a good move - this is not always the desired behavior. I can name a few Vorpal apps in which the app doesn't exit after parsing.

dthree avatar Aug 05 '16 06:08 dthree

I see your point. See this stackoverflow that you answered:

http://stackoverflow.com/questions/33489201/is-it-possible-to-create-a-vorpal-application-which-the-commands-output-goes-di

You can have the app exit after completing the command simply by omitting vorpal.show(). Because there is no prompt, Node realizes there is nothing left to do, and the process will exit naturally.

The issue is that after my PR has been merged, there is a UI attached to the parse function. So Node will not exit naturally.

Any recommended way to fix this problem?

alansouzati avatar Aug 05 '16 17:08 alansouzati

Okay... trying to find the best way to solve this.

I think we need to add in options to parse - something like:

vorpal.parse(process.argv, {survive: true});

With this, the default behavior will be to exit, and if a flag is passed, the exit will be omitted.

I don't really like survive though. Got a better name?

dthree avatar Aug 06 '16 16:08 dthree

👍 I like the idea of having options/config for parsing

keepAlive is certainly better than survive

ruyadorno avatar Aug 06 '16 16:08 ruyadorno

Hahaha right? Just woke up, mind not functioning.

@alansouzati would you be willing to add a keepAlive flag to your PR?

dthree avatar Aug 06 '16 16:08 dthree

You bet, great idea guys. Will add that tomorrow.

Alan

On Aug 6, 2016, at 9:34 AM, dc [email protected] wrote:

Hahaha right? Just woke up, mind not functioning.

@alansouzati would you be willing to add a keepAlive flag to your PR?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

alansouzati avatar Aug 06 '16 16:08 alansouzati

Added the keepAlive, I believe we are good to go now 💃

alansouzati avatar Aug 08 '16 18:08 alansouzati

fixed :)

alansouzati avatar Aug 08 '16 20:08 alansouzati

@alansouzati tried your branch with the mentioned fix from above but I still have one annoying issue, which is that the interactive shell prefix gets printed twice when I execute a command, e.g:

ad help
local@macbookpro~$

  Commands:

    help [command...]           Provides help for a given command.
    exit                        Exits application.
    ...

local@macbookpro~$

where macbookpro is my Hostname :)

ruyadorno avatar Aug 08 '16 20:08 ruyadorno

I think that's probably due to the fact that the ui attaches itself and then executes an exit command but I'd like your inputs on it before jumping into any conclusions...

ruyadorno avatar Aug 08 '16 20:08 ruyadorno

@alansouzati if we don't resolve this shortly, I'm going to have to revert that last PR. Willing to look into additional fixes for a little though.

dthree avatar Aug 08 '16 20:08 dthree

Yeah. I have the same issue.

Well, I believe printing the current delimiter is less impactful than not supporting prompt for inline commands.

See this issue for reference:

https://github.com/dthree/vorpal/issues/164

alansouzati avatar Aug 08 '16 20:08 alansouzati

I can try and investigate why the delimiter in being printed in this case, but I believe this is a separate issue from "exit on parse".

alansouzati avatar Aug 08 '16 20:08 alansouzati

👍 makes sense,

@dthree IMHO it's preferable to merge this the way it is instead of reverting, a fix for the extra delimiters printed can wait more

ruyadorno avatar Aug 08 '16 20:08 ruyadorno

In the case of the delimiter, I believe if keepAlive is false we should never print it.

alansouzati avatar Aug 08 '16 20:08 alansouzati

Okay. I would like to see if we could figure this delimiter thing out though... don't want to merge this and then have it forgotten about.

dthree avatar Aug 08 '16 20:08 dthree

Do you agree with this statement: "if keepAlive is false we should never print the delimiter." ?

alansouzati avatar Aug 08 '16 20:08 alansouzati

@dthree in a second thought, maybe a revert is really a good idea in this case

seeing #172 it seems other people are suffering from the ui attach change as a breaking change

adding the keepAlive options is at best a new feature and should yield a new minor version but to be honest even with this option it still a breaking change in the API for many consuming applications out there and a new major version release would probably be better for everyone

ruyadorno avatar Aug 08 '16 20:08 ruyadorno

agreed with @ruyadorno. maybe we need a major release as it is a breaking change.

But I believe we don't necessarily need to revert the change in Git to revert it in NPM.

alansouzati avatar Aug 08 '16 20:08 alansouzati

I'm pushing the fix for the delimiter here for you guys to evaluate.

alansouzati avatar Aug 08 '16 20:08 alansouzati

Ok, can you take a look now? If keepAlive is false no delimiter will be printed.

alansouzati avatar Aug 08 '16 21:08 alansouzati

But I believe we don't necessarily need to revert the change in Git to revert it in NPM.

The git repo should always reflect NPM, for users' sake.

dthree avatar Aug 08 '16 21:08 dthree

@alansouzati just updated my project with the latest changes and I can confirm that this fixes the extra delimiters printed issue 👍

thank you so much for all the work on this 😊

ruyadorno avatar Aug 08 '16 21:08 ruyadorno

thanks for trying it out @ruyadorno.

It seems that we will need to wait until @dthree figures out the side effects of this change.

alansouzati avatar Aug 08 '16 21:08 alansouzati

@alansouzati I have yet another very tricky situation, I actually have a mixed of interactive and non-interactive (keepAlive:false) commands in my cli app - @dthree is that supposed to be a supported use case?

in this situation it would be nice to have a way to define the keepAlive option from within the command definition instead...

ruyadorno avatar Aug 09 '16 17:08 ruyadorno

hey @dthree any updates on this?

I have few folks complaining about the grommet new sample-app hanging the UI. I really want to avoid a three step process like

  1. grommet
  2. new sample-app
  3. exit

alansouzati avatar Aug 10 '16 03:08 alansouzati

Actually no rush anymore. I added my fork branch in my package.json for now.

https://github.com/grommet/grommet-cli/blob/master/package.json#L27

alansouzati avatar Aug 10 '16 03:08 alansouzati