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

feat: allow custom exit command implementation #275

Merged
merged 6 commits into from Jul 29, 2021
Merged

feat: allow custom exit command implementation #275

merged 6 commits into from Jul 29, 2021

Conversation

axelrindle
Copy link
Contributor

I'm creating a CLI which runs in an async context with init and dispose hooks. Just calling process.exit() when the user types exit may be fatal.

This change allows for custom implementation for an exit command.

@hongaar
Copy link
Owner

hongaar commented Jul 28, 2021

Thanks for creating this PR. I'm in favour of such a change.

I suggest a slightly different implementation though: make this option part of the global options passed to the Program constructor. Let's just call it exit to align better with the existing help and version options. What about it could take false or a function as value and defaults to () => process.exit(), would that work for your use case?

@axelrindle
Copy link
Contributor Author

I suggest a slightly different implementation though...

Got it. Will implement this tomorrow.

What about it could take false or a function as value and defaults to () => process.exit(), would that work for your use case?

Yes. I will add that.

@axelrindle
Copy link
Contributor Author

Ok, everything should be implemented now.

Copy link
Owner

@hongaar hongaar left a comment

Choose a reason for hiding this comment

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

Looks good to me, can you address the comment and add a description to the README? Then it's good to go. (If you can, a test for this would be appreciated)

src/program.ts Outdated Show resolved Hide resolved
@axelrindle
Copy link
Contributor Author

I'm not familiar with jest, I suggest you add that test 😅

Copy link
Owner

@hongaar hongaar left a comment

Choose a reason for hiding this comment

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

Thanks for the PR!

@hongaar hongaar enabled auto-merge (squash) July 29, 2021 21:29
@hongaar hongaar merged commit 9527735 into hongaar:main Jul 29, 2021
@axelrindle axelrindle deleted the feature/find-command branch July 29, 2021 21:33
github-actions bot pushed a commit that referenced this pull request Jul 29, 2021
# [1.7.0](v1.6.4...v1.7.0) (2021-07-29)

### Features

* allow custom exit command implementation ([#275](#275)) ([9527735](9527735))

[skip ci]
@hongaar
Copy link
Owner

hongaar commented Jul 29, 2021

🎉 This PR is included in version 1.7.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Successfully merging this pull request may close these issues.

2 participants