Optional msg argument to leiningen.core.main/exit. Use it for abort. #1437

Merged
merged 1 commit into from Mar 6, 2014

Conversation

4 participants
Contributor

laurentpetit commented Feb 7, 2014

  • New signature: leiningen.core.main/exit [exit-code & msg]
  • msg used when exit-process? is false as the Exception message

The following issues have been created for projects which are (lein-junit, test2junit) or might (pallet/pallet, pallet/nrepl-main) be impacted by this change:

Optional msg argument to leiningen.core.main/exit. Use it for abort.
- New signature: leiningen.core.main/exit [exit-code & msg]
- msg used when *exit-process?* is false as the Exception message
Contributor

benwbooth commented Feb 7, 2014

Would it be possible to print nothing instead of "Suppressed exit" if no message is provided? I'm using lein exec with grenchman to run clojure command-line scripts. Right now, every script always prints a "Suppressed exit" message when the script exits, which is really annoying. The only workaround I've found is to exit scripts explicitly using (throw (ex-info nil {:exit-code 0 :suppress-msg true})). This is quite ugly. I'd much rather be able to say (exit 0) or (leiningen.core.main/exit 0). Since an abort message can now be explicitly provided, I think it makes sense to not display anything by default.

Contributor

laurentpetit commented Feb 7, 2014

As far as I can tell, leiningen.core.main/exit doesn't print anything to stderr, it's leiningen.core.main/abort which does that (even after the pull request).
Maybe this can be handled as a separate issue.

Contributor

benwbooth commented Feb 7, 2014

The "Suppressed exit" gets printed to stdout on line 322 of leiningen.core.main/-main, when the exit exception is caught. But this only happens if *exit-process?* is set to false.

Collaborator

hypirion commented Feb 8, 2014

I was thinking it would be reasonable to somehow ensure that you can detect that this was thrown by Leiningen's abort/exit function. Something like the #1440 :suppress-msg true might work, but I think we have to be a bit careful with respect to backwards compatibility. Perhaps even wait until 3.0? Not sure, Phil probably has a better idea on what is sensible or not.

I think another change here is that abort messages will be printed twice in some core commands, although I am not completely sure about that. I'll have a look into that later.

The pull request itself seems good, though. I just think the implications has to be considered. =)

@technomancy technomancy merged commit c28f03a into technomancy:master Mar 6, 2014

1 check passed

default The Travis CI build passed
Details
Owner

technomancy commented Mar 6, 2014

Sorry for the delay on this. Just merged it in. There were a few weird situations where this affected the tests, but I don't think there will be much in the way of compatibility issues affecting plugins.

@febeling febeling referenced this pull request in febeling/lein-junit Jan 5, 2015

Closed

Test file detection pattern should be an option #24

febeling added a commit to febeling/lein-junit that referenced this pull request Jan 5, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment