-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
OnKillRun feature #1914
base: main
Are you sure you want to change the base?
OnKillRun feature #1914
Conversation
This is a good idea...we had to implement this outside of cobra (which is fine.) But I think this establishes a good practice that all CLI's should have OOB. Some lint issues to clean up, at a quick glance it should be safe to annotate out |
@decanus Sorry for the delay. Can you rebase this to make CI pass? |
@marckhouzam done! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is really great @decanus ! I love it!
I would like to include it in the next release of Cobra.
Would you be able to add a small paragraph of documentation after this section https://github.com/spf13/cobra/blob/main/site/content/user_guide.md#prerun-and-postrun-hooks
And a unit test would be important to make sure this does not break in the future.
Finally, there are a couple of linter errors to fix.
Thanks a lot!
I was thinking about how this new feature would be used. I like the fact that the Would that be a likely scenario? |
@decanus Are you still interested in getting this merged? |
syscall.SIGINT, | ||
syscall.SIGKILL, | ||
syscall.SIGTERM, | ||
syscall.SIGQUIT, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we also need os.Interrupt
for things to work on Windows
found this through google - would be nice to get this finished and merged, but i guess for now i'll have to roll my own signal handler |
I'm still interested in merging this @decanus but CI is failing. |
A helper to run a function if a command is killed.