From 35b053716e9859accb99a2bb0adb3f67dd4b093f Mon Sep 17 00:00:00 2001 From: Mikhail Sandakov Date: Fri, 26 Apr 2024 16:19:11 +0300 Subject: [PATCH] Support --version parameter after conversion is done --- pleskdistup/main.py | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/pleskdistup/main.py b/pleskdistup/main.py index 92bc522..a7b814f 100644 --- a/pleskdistup/main.py +++ b/pleskdistup/main.py @@ -447,6 +447,21 @@ def main(): log.debug(f"Looking for upgrader by the name '{options.upgrader_name}'") upgraders = list(pleskdistup.registry.iter_upgraders(upgrader_name=options.upgrader_name)) log.debug(f"Found upgraders: {upgraders}") + + if options.version: + if not upgraders: + upgraders = list(pleskdistup.registry.iter_upgraders()) + if len(upgraders) != 1: + printerr(f"Couldn't get upgrader name. Please provide upgrader name by --upgrader-name. Available upgraders: {upgraders}") + return 1 + + upgrader = upgraders[0].create_upgrader() + print( + f"Plesk dist-upgrader {pleskdistup.config.revision}.\n" + f"{upgrader.upgrader_name} {upgrader.upgrader_version}." + ) + return 0 + if not upgraders: printerr(f"No upgraders found for your system ({distro})") return 1 @@ -483,12 +498,7 @@ def main(): ) upgrader.parse_args(["--help"]) parser.exit() - if options.version: - print( - f"Plesk dist-upgrader {pleskdistup.config.revision}.\n" - f"{upgrader.upgrader_name} {upgrader.upgrader_version}." - ) - return 0 + upgrader.parse_args(extra_args) if options.prepare_feedback: