Skip to content

Commit

Permalink
CLI: update cmdline deprecate decorator to include version
Browse files Browse the repository at this point in the history
  • Loading branch information
agoscinski committed May 28, 2024
1 parent 9e3ebf6 commit 6051909
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/aiida/cmdline/utils/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ def do_circus_stuff():
return wrapped(*args, **kwargs)


def deprecated_command(message):
def deprecated_command(message, version=None):
"""Function decorator that will mark a click command as deprecated when invoked.
Example::
Expand All @@ -259,7 +259,10 @@ def wrapper(wrapped, _, args, kwargs):

template = templates.env.get_template('deprecated.tpl')
width = 80
echo.echo(template.render(msg=wrap(message, width - 4), width=width))
message_ = message
if version is not None:
message_ = f'{message_} (this will be removed in v{version})'
echo.echo(template.render(msg=wrap(message_, width - 4), width=width))

return wrapped(*args, **kwargs)

Expand Down

0 comments on commit 6051909

Please sign in to comment.