Let the wrapped mains take additional arguments.

Just in case the application wants to do so.
This commit is contained in:
voussoir 2021-10-30 17:27:05 -07:00
parent 73e722fa7b
commit 38de31f1e2
No known key found for this signature in database
GPG key ID: 5F7554F8C26DACCB
2 changed files with 5 additions and 5 deletions

View file

@ -239,14 +239,14 @@ def main_decorator(subject, *, log_return_value=True, **kwargs):
3. Wrap main call with main_log_context.
'''
def wrapper(main):
def wrapped(argv):
def wrapped(argv, *args, **kwargs):
(argv, level) = get_level_by_argv(argv)
if level is None:
return main(argv)
return main(argv, *args, **kwargs)
context = main_log_context(subject, level, **kwargs)
with context:
status = main(argv)
status = main(argv, *args, **kwargs)
if log_return_value:
log.info('Program finished, returned %s.', status)
return status

View file

@ -182,8 +182,8 @@ def main_decorator(main):
to use --debug, --quiet, etc. on the command line without making any
changes to your argparser.
'''
def wrapped(argv):
def wrapped(argv, *args, **kwargs):
(level, argv) = get_level_by_argv(argv)
add_root_handler(level)
return main(argv)
return main(argv, *args, **kwargs)
return wrapped