From 0ceae62701731f8b32c34d7993a34dea34aea59c Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Tue, 17 May 2022 21:11:29 +0300 Subject: [PATCH] Better informing about deprecated commands --- platformio/commands/lib/command.py | 42 +++++++++++++++++++++++----- platformio/commands/platform.py | 44 +++++++++++++++++++++++++----- 2 files changed, 72 insertions(+), 14 deletions(-) diff --git a/platformio/commands/lib/command.py b/platformio/commands/lib/command.py index 7e3f08e1..367a80d6 100644 --- a/platformio/commands/lib/command.py +++ b/platformio/commands/lib/command.py @@ -69,13 +69,6 @@ def get_project_global_lib_dir(): @click.pass_context def cli(ctx, **options): in_silence = PlatformioCLI.in_silence() - if not in_silence: - click.secho( - "\nWARNING!!! This command is deprecated and will be removed in " - "the next releases. \nPlease use `pio pkg` instead.\n", - fg="yellow", - ) - storage_cmds = ("install", "uninstall", "update", "list") # skip commands that don't need storage folder if ctx.invoked_subcommand not in storage_cmds or ( @@ -148,6 +141,11 @@ def cli(ctx, **options): def lib_install( # pylint: disable=too-many-arguments,unused-argument ctx, libraries, save, silent, interactive, force ): + click.secho( + "\nWARNING: This command is deprecated and will be removed in " + "the next releases. \nPlease use `pio pkg install` instead.\n", + fg="yellow", + ) storage_dirs = ctx.meta[CTX_META_STORAGE_DIRS_KEY] storage_libdeps = ctx.meta.get(CTX_META_STORAGE_LIBDEPS_KEY, []) @@ -211,6 +209,11 @@ def _save_deps(ctx, pkgs, action="add"): @click.option("-s", "--silent", is_flag=True, help="Suppress progress reporting") @click.pass_context def lib_uninstall(ctx, libraries, save, silent): + click.secho( + "\nWARNING: This command is deprecated and will be removed in " + "the next releases. \nPlease use `pio pkg uninstall` instead.\n", + fg="yellow", + ) storage_dirs = ctx.meta[CTX_META_STORAGE_DIRS_KEY] uninstalled_pkgs = {} for storage_dir in storage_dirs: @@ -246,6 +249,13 @@ def lib_update( # pylint: disable=too-many-arguments "This command is deprecated, please use `pio pkg outdated` instead" ) + if not json_output: + click.secho( + "\nWARNING: This command is deprecated and will be removed in " + "the next releases. \nPlease use `pio pkg update` instead.\n", + fg="yellow", + ) + storage_dirs = ctx.meta[CTX_META_STORAGE_DIRS_KEY] json_result = {} for storage_dir in storage_dirs: @@ -305,6 +315,12 @@ def lib_update( # pylint: disable=too-many-arguments @click.option("--json-output", is_flag=True) @click.pass_context def lib_list(ctx, json_output): + if not json_output: + click.secho( + "\nWARNING: This command is deprecated and will be removed in " + "the next releases. \nPlease use `pio pkg list` instead.\n", + fg="yellow", + ) storage_dirs = ctx.meta[CTX_META_STORAGE_DIRS_KEY] json_result = {} for storage_dir in storage_dirs: @@ -348,6 +364,12 @@ def lib_list(ctx, json_output): help="Do not prompt, automatically paginate with delay", ) def lib_search(query, json_output, page, noninteractive, **filters): + if not json_output: + click.secho( + "\nWARNING: This command is deprecated and will be removed in " + "the next releases. \nPlease use `pio pkg search` instead.\n", + fg="yellow", + ) regclient = LibraryPackageManager().get_registry_client_instance() if not query: query = [] @@ -444,6 +466,12 @@ def lib_builtin(storage, json_output): @click.argument("library", metavar="[LIBRARY]") @click.option("--json-output", is_flag=True) def lib_show(library, json_output): + if not json_output: + click.secho( + "\nWARNING: This command is deprecated and will be removed in " + "the next releases. \nPlease use `pio pkg show` instead.\n", + fg="yellow", + ) lm = LibraryPackageManager() lm.set_log_level(logging.ERROR if json_output else logging.DEBUG) lib_id = lm.reveal_registry_package_id(library) diff --git a/platformio/commands/platform.py b/platformio/commands/platform.py index ae80566e..d9e8af2d 100644 --- a/platformio/commands/platform.py +++ b/platformio/commands/platform.py @@ -18,7 +18,6 @@ import os import click -from platformio.commands import PlatformioCLI from platformio.commands.boards import print_boards from platformio.exception import UserSideException from platformio.package.exception import UnknownPackageError @@ -31,18 +30,19 @@ from platformio.platform.factory import PlatformFactory @click.group(short_help="Platform manager", hidden=True) def cli(): - if not PlatformioCLI.in_silence(): - click.secho( - "\nWARNING!!! This command is deprecated and will be removed in " - "the next releases. \nPlease use `pio pkg` instead.\n", - fg="yellow", - ) + pass @cli.command("search", short_help="Search for development platform") @click.argument("query", required=False) @click.option("--json-output", is_flag=True) def platform_search(query, json_output): + if not json_output: + click.secho( + "\nWARNING: This command is deprecated and will be removed in " + "the next releases. \nPlease use `pio pkg search` instead.\n", + fg="yellow", + ) platforms = [] for platform in _get_registry_platforms(): if query == "all": @@ -94,6 +94,12 @@ def platform_frameworks(query, json_output): @cli.command("list", short_help="List installed development platforms") @click.option("--json-output", is_flag=True) def platform_list(json_output): + if not json_output: + click.secho( + "\nWARNING: This command is deprecated and will be removed in " + "the next releases. \nPlease use `pio pkg list` instead.\n", + fg="yellow", + ) platforms = [] pm = PlatformPackageManager() for pkg in pm.get_installed(): @@ -112,6 +118,12 @@ def platform_list(json_output): @click.argument("platform") @click.option("--json-output", is_flag=True) def platform_show(platform, json_output): # pylint: disable=too-many-branches + if not json_output: + click.secho( + "\nWARNING: This command is deprecated and will be removed in " + "the next releases. \nPlease use `pio pkg show` instead.\n", + fg="yellow", + ) data = _get_platform_data(platform) if not data: raise UnknownPlatform(platform) @@ -195,6 +207,12 @@ def platform_install( # pylint: disable=too-many-arguments,too-many-locals silent, force, ): + click.secho( + "\nWARNING: This command is deprecated and will be removed in " + "the next releases. \nPlease use `pio pkg install` instead.\n", + fg="yellow", + ) + def _find_pkg_names(p, candidates): result = [] for candidate in candidates: @@ -251,6 +269,11 @@ def platform_install( # pylint: disable=too-many-arguments,too-many-locals @cli.command("uninstall", short_help="Uninstall development platform") @click.argument("platforms", nargs=-1, required=True, metavar="[PLATFORM...]") def platform_uninstall(platforms): + click.secho( + "\nWARNING: This command is deprecated and will be removed in " + "the next releases. \nPlease use `pio pkg uninstall` instead.\n", + fg="yellow", + ) pm = PlatformPackageManager() pm.set_log_level(logging.DEBUG) for platform in platforms: @@ -285,6 +308,13 @@ def platform_update( # pylint: disable=too-many-locals, too-many-arguments "This command is deprecated, please use `pio pkg outdated` instead" ) + if not json_output: + click.secho( + "\nWARNING: This command is deprecated and will be removed in " + "the next releases. \nPlease use `pio pkg update` instead.\n", + fg="yellow", + ) + pm = PlatformPackageManager() pm.set_log_level(logging.WARN if silent else logging.DEBUG) platforms = platforms or pm.get_installed()