cobra icon indicating copy to clipboard operation
cobra copied to clipboard

OnKillRun feature

Open decanus opened this issue 2 years ago • 9 comments

A helper to run a function if a command is killed.

decanus avatar Feb 16 '23 15:02 decanus

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar Feb 16 '23 15:02 CLAassistant

Cool idea @decanus ! I haven't tried it out yet but it looks useful. This will need some tests and documentation. cc @jpmcb

marckhouzam avatar Feb 25 '23 23:02 marckhouzam

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 SA1017. Not sure about the others...

talbright avatar Mar 11 '23 05:03 talbright

@decanus Sorry for the delay. Can you rebase this to make CI pass?

marckhouzam avatar Oct 13 '23 19:10 marckhouzam

@marckhouzam done!

decanus avatar Oct 13 '23 20:10 decanus

I was thinking about how this new feature would be used. I like the fact that the OnKillRun can be defined for a specific command. But what if I wanted to create a global OnKillRun for all the commands? For example to always intercept ^C?

Would that be a likely scenario?

marckhouzam avatar Oct 16 '23 01:10 marckhouzam

@decanus Are you still interested in getting this merged?

marckhouzam avatar Dec 29 '23 19:12 marckhouzam

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

rojer avatar Jun 19 '24 22:06 rojer

I'm still interested in merging this @decanus but CI is failing. Also, a very small doc and test would be important.

marckhouzam avatar Jul 08 '24 13:07 marckhouzam