Skip to content

Commit 45e9948

Browse files
log nutils version in cli.run, choose
This patch adds the _util.log_version context that logs the nutils version and release name, and adds it to the context list of cli.run so that the version is shown prior to any other output.
1 parent 078af53 commit 45e9948

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

nutils/_util.py

+12
Original file line numberDiff line numberDiff line change
@@ -491,6 +491,18 @@ def in_context(*args, **kwargs):
491491
return in_context_wrapper
492492

493493

494+
def log_version(f):
495+
496+
from . import version, version_name
497+
498+
@functools.wraps(f)
499+
def log_version(*args, **kwargs):
500+
treelog.info(f'NUTILS {version} "{version_name.title()}"')
501+
return f(*args, **kwargs)
502+
503+
return log_version
504+
505+
494506
def log_arguments(f):
495507
'''Decorator to log a function's arguments.
496508

nutils/cli.py

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ def run(f, *, argv=None):
2323
util.in_context(util.log_traceback),
2424
util.in_context(util.post_mortem),
2525
warnings.via(treelog.warning),
26+
util.log_version,
2627
util.log_arguments,
2728
util.timeit(),
2829
)

0 commit comments

Comments
 (0)