Closed jaraco closed 1 year ago
I like your 3 options. I agree with you that this would be outside of automain
, which is primarily about handling __name__ == "__main__"
. My approach would be to add a 4th decorator to the stack of nested decorators that are assembled by autocommand
: https://github.com/Lucretiel/autocommand/blob/9d95de8ad227a76604a9205b5b211bc2a0576e91/src/autocommand/autocommand.py#L40-L66
I've started work on a patch for #18. In this PR, the
automain
accepts a new optional parameteron_interrupt
, which can beignore
(the default and current behavior),suppress
(suppress the exception and exit 0), orquiet
(exit 1 without a traceback).I ran into a bit of difficulty when trying to wire it into automain and especially when trying to wire that through autocommand. The current approach allows
autocommand
to accept a newautomain
parameter, overriding the defaultautomain
, such as withautocommand(automain=functools.partial(autocommand.automain, on_interrupt='quiet'))
. I don't love that interface.And now that I think about it more, I'm not sure having this functionality integrated with automain makes any sense at all, and maybe there should just be a new, independent decorator for interrupt handling.
Still, I'd like to submit this for your consideration - are there any behaviors from this approach that you'd like to see in the final approach?