Fix Click's "DeprecationWarning: 'resultcallback' has been renamed to 'result_callback'" // Resolve #4075

This commit is contained in:
Ivan Kravets
2021-10-08 15:18:34 +03:00
parent 3d46f0d72f
commit b04bb2b740

View File

@ -67,9 +67,24 @@ def cli(ctx, force, caller, no_ansi):
maintenance.on_platformio_start(ctx, force, caller)
@cli.resultcallback()
@click.pass_context
def process_result(ctx, result, *_, **__):
try:
@cli.result_callback()
@click.pass_context
def process_result(ctx, result, *_, **__):
_process_result(ctx, result)
except (AttributeError, TypeError): # legacy support for CLick > 8.0.1
print("legacy Click")
@cli.resultcallback()
@click.pass_context
def process_result(ctx, result, *_, **__):
_process_result(ctx, result)
def _process_result(ctx, result):
from platformio import maintenance
maintenance.on_platformio_end(ctx, result)