Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exit on parse #169

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open

Exit on parse #169

wants to merge 6 commits into from

Conversation

alansouzati
Copy link
Contributor

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

@dthree
Copy link
Owner

dthree commented Aug 5, 2016

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.

@alansouzati
Copy link
Contributor Author

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?

@dthree
Copy link
Owner

dthree commented Aug 6, 2016

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?

@ruyadorno
Copy link

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

keepAlive is certainly better than survive

@dthree
Copy link
Owner

dthree commented Aug 6, 2016

Hahaha right? Just woke up, mind not functioning.

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

@alansouzati
Copy link
Contributor Author

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

Alan

On Aug 6, 2016, at 9:34 AM, dc notifications@github.com 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
Copy link
Contributor Author

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

lib/vorpal.js Outdated
if (!options.keepAlive) {
// Exits the CLI context as the UI is still attached
this.exec('exit');
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't this block be placed outside of the if (err) block?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, this should definitely run outside of the error block.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whops. not sure what happened here. shame on me 😲

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hahaha less shame, more tests.

Fixed wrong place for check
@alansouzati
Copy link
Contributor Author

fixed :)

@ruyadorno
Copy link

@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
Copy link

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

@dthree
Copy link
Owner

dthree commented Aug 8, 2016

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

@alansouzati
Copy link
Contributor Author

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:

#164

@alansouzati
Copy link
Contributor Author

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

@ruyadorno
Copy link

👍 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

@alansouzati
Copy link
Contributor Author

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

@dthree
Copy link
Owner

dthree commented Aug 8, 2016

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.

@alansouzati
Copy link
Contributor Author

alansouzati commented Aug 8, 2016

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

@ruyadorno
Copy link

@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

@alansouzati
Copy link
Contributor Author

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
Copy link
Contributor Author

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

@alansouzati
Copy link
Contributor Author

alansouzati commented Aug 8, 2016

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

@@ -157,7 +160,7 @@ session.delimiter = function (str) {
if (str === undefined) {
return this._delimiter;
}
this._delimiter = String(str).trim() + ' ';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Im not sure why we are adding this empty space here.

Copy link
Owner

@dthree dthree Aug 8, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The prompt delimiter is a very touchy subject, and if you look in the issue history, there's a lot of subtle bug fixes involved with it. Be careful before changing things, as seeming fixes can break a lot of other things in this area.


I haven't been able to break out some code to test these things as I've been swamped, so sorry for not giving too much insight. Trying to do that as soon as possible, but I think for now we should just revert instead of piling fixes on fixes which break fixes which require more fixes.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you bet. the PR is here anyways. let me know how I can help.

I did everything I could for now. I believe the ball is in your court now.

Let me know when you revert the changes so that I can re-open the issue with the ability to run prompts inside the parse context.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand that sometimes we need to add fixes that are not necessarily intuitive enough. I tend to add comments around it anytime I have to do things like that.

This way it helps future developers working on the library.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot!! 👍

@dthree
Copy link
Owner

dthree commented Aug 8, 2016

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.

@ruyadorno
Copy link

@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 😊

@alansouzati
Copy link
Contributor Author

thanks for trying it out @ruyadorno.

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

@ruyadorno
Copy link

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

@alansouzati
Copy link
Contributor Author

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
Copy link
Contributor Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants