diff --git a/platformio/package/manager/_update.py b/platformio/package/manager/_update.py index 3b6dd2d4..1487d0bf 100644 --- a/platformio/package/manager/_update.py +++ b/platformio/package/manager/_update.py @@ -104,7 +104,7 @@ class PackageManagerUpdateMixin(object): outdated = self.outdated(pkg, to_spec) if not silent: - self.print_outdated_state(outdated, show_incompatible) + self.print_outdated_state(outdated, only_check, show_incompatible) if only_check or not outdated.is_outdated(allow_incompatible=False): return pkg @@ -116,24 +116,39 @@ class PackageManagerUpdateMixin(object): self.unlock() @staticmethod - def print_outdated_state(outdated, show_incompatible=True): + def print_outdated_state(outdated, only_check, show_incompatible): if outdated.detached: return click.echo("[%s]" % (click.style("Detached", fg="yellow"))) + if ( not outdated.latest or outdated.current == outdated.latest or (not show_incompatible and outdated.current == outdated.wanted) ): return click.echo("[%s]" % (click.style("Up-to-date", fg="green"))) + if outdated.wanted and outdated.current == outdated.wanted: return click.echo( "[%s]" % (click.style("Incompatible %s" % outdated.latest, fg="yellow")) ) + + if only_check: + return click.echo( + "[%s]" + % ( + click.style( + "Outdated %s" % str(outdated.wanted or outdated.latest), + fg="red", + ) + ) + ) + return click.echo( "[%s]" % ( click.style( - "Outdated %s" % str(outdated.wanted or outdated.latest), fg="red" + "Updating to %s" % str(outdated.wanted or outdated.latest), + fg="green", ) ) ) diff --git a/tests/test_maintenance.py b/tests/test_maintenance.py index 46bc82c8..0d863b0d 100644 --- a/tests/test_maintenance.py +++ b/tests/test_maintenance.py @@ -91,7 +91,7 @@ def test_check_and_update_libraries(clirunner, isolated_pio_core, validate_clire assert "There are the new updates for libraries (ArduinoJson)" in result.output assert "Please wait while updating libraries" in result.output assert re.search( - r"Updating bblanchon/ArduinoJson\s+6\.12\.0\s+\[Outdated [\d\.]+\]", + r"Updating bblanchon/ArduinoJson\s+6\.12\.0\s+\[Updating to [\d\.]+\]", result.output, ) @@ -143,7 +143,9 @@ def test_check_and_update_platforms(clirunner, isolated_pio_core, validate_clire validate_cliresult(result) assert "There are the new updates for platforms (native)" in result.output assert "Please wait while updating platforms" in result.output - assert re.search(r"Updating native\s+0.0.0\s+\[Outdated [\d\.]+\]", result.output) + assert re.search( + r"Updating native\s+0.0.0\s+\[Updating to [\d\.]+\]", result.output + ) # check updated version result = clirunner.invoke(cli_pio, ["platform", "list", "--json-output"])