From aaf61082c1c570c6780eb3b82febe89f31c88012 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Thu, 16 May 2019 20:02:45 +0300 Subject: [PATCH] Replace "--only-check" CLI option by "--dry-run" --- HISTORY.rst | 1 + docs | 2 +- platformio/commands/lib.py | 10 ++++++++-- platformio/commands/platform.py | 11 +++++++++-- platformio/commands/remote.py | 8 ++++++-- platformio/commands/update.py | 11 +++++++++-- platformio/maintenance.py | 2 +- 7 files changed, 35 insertions(+), 10 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index f5a953f6..5f0dd973 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -18,6 +18,7 @@ PlatformIO 4.0 * Override default source and include directories for a library via `library.json `__ manifest using ``includeDir`` and ``srcDir`` fields * Added support for the latest Python "Click" package (CLI Builder) (`issue #349 `_) +* Deprecated ``--only-check`` CLI option for "update" sub-commands, please use ``--dry-run`` instead PlatformIO 3.0 -------------- diff --git a/docs b/docs index 700a8ac4..6e000475 160000 --- a/docs +++ b/docs @@ -1 +1 @@ -Subproject commit 700a8ac46791bf06ce43d2efe5e22147e0178d38 +Subproject commit 6e0004755ac1849b66cf45ec8e0fca47a35226e0 diff --git a/platformio/commands/lib.py b/platformio/commands/lib.py index c52350b1..dde2aa0b 100644 --- a/platformio/commands/lib.py +++ b/platformio/commands/lib.py @@ -123,13 +123,19 @@ def lib_uninstall(lm, libraries): "-c", "--only-check", is_flag=True, - help="Do not update, only check for new version") + help="DEPRECATED. Please use `--dry-run` instead") +@click.option( + "--dry-run", + is_flag=True, + help="Do not update, only check for the new versions") @click.option("--json-output", is_flag=True) @click.pass_obj -def lib_update(lm, libraries, only_check, json_output): +def lib_update(lm, libraries, only_check, dry_run, json_output): if not libraries: libraries = [manifest['__pkg_dir'] for manifest in lm.get_installed()] + only_check = dry_run or only_check + if only_check and json_output: result = [] for library in libraries: diff --git a/platformio/commands/platform.py b/platformio/commands/platform.py index bf7ecf75..db0149f3 100644 --- a/platformio/commands/platform.py +++ b/platformio/commands/platform.py @@ -329,9 +329,14 @@ def platform_uninstall(platforms): "-c", "--only-check", is_flag=True, - help="Do not update, only check for a new version") + help="DEPRECATED. Please use `--dry-run` instead") +@click.option( + "--dry-run", + is_flag=True, + help="Do not update, only check for the new versions") @click.option("--json-output", is_flag=True) -def platform_update(platforms, only_packages, only_check, json_output): +def platform_update(platforms, only_packages, only_check, dry_run, + json_output): pm = PlatformManager() pkg_dir_to_name = {} if not platforms: @@ -341,6 +346,8 @@ def platform_update(platforms, only_packages, only_check, json_output): pkg_dir_to_name[manifest['__pkg_dir']] = manifest.get( "title", manifest['name']) + only_check = dry_run or only_check + if only_check and json_output: result = [] for platform in platforms: diff --git a/platformio/commands/remote.py b/platformio/commands/remote.py index d506d5a5..b37e843c 100644 --- a/platformio/commands/remote.py +++ b/platformio/commands/remote.py @@ -68,8 +68,12 @@ def remote_agent_list(): "-c", "--only-check", is_flag=True, - help="Do not update, only check for new version") -def remote_update(only_check): + help="DEPRECATED. Please use `--dry-run` instead") +@click.option( + "--dry-run", + is_flag=True, + help="Do not update, only check for the new versions") +def remote_update(only_check, dry_run): pioplus_call(sys.argv[1:]) diff --git a/platformio/commands/update.py b/platformio/commands/update.py index 924fb290..d72a35d4 100644 --- a/platformio/commands/update.py +++ b/platformio/commands/update.py @@ -29,12 +29,19 @@ from platformio.managers.lib import LibraryManager "-c", "--only-check", is_flag=True, - help="Do not update, only check for new version") + help="DEPRECATED. Please use `--dry-run` instead") +@click.option( + "--dry-run", + is_flag=True, + help="Do not update, only check for the new versions") +@click.option("--json-output", is_flag=True) @click.pass_context -def cli(ctx, core_packages, only_check): +def cli(ctx, core_packages, only_check, dry_run): # cleanup lib search results, cached board and platform lists app.clean_cache() + only_check = dry_run or only_check + update_core_packages(only_check) if core_packages: diff --git a/platformio/maintenance.py b/platformio/maintenance.py index 8841b7f5..4bebcb7b 100644 --- a/platformio/maintenance.py +++ b/platformio/maintenance.py @@ -329,7 +329,7 @@ def check_internal_updates(ctx, what): fg="yellow", nl=False) click.secho( - "`platformio %s update --only-check`" % + "`platformio %s update --dry-run`" % ("lib --global" if what == "libraries" else "platform"), fg="cyan", nl=False)