diff --git a/HISTORY.rst b/HISTORY.rst index f8283452..b4fd0ac6 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -10,6 +10,7 @@ PlatformIO Core 4.0 ~~~~~~~~~~~~~~~~~~ * Extend project environment configuration in "platformio.ini" with other sections using a new `extends `__ option (`issue #2953 `_) +* New ``--no-ansi`` flag for `PIO Core `__ to disable ANSI control characters * Generate ``.ccls`` LSP file for `Emacs `__ cross references, hierarchies, completion and semantic highlighting * Fixed an issue with project generator for `CLion IDE `__ when 2 environments were used (`issue #2824 `_) * Fixed default PIO Unified Debugger configuration for `J-Link probe `__ diff --git a/docs b/docs index 10d5ce9d..52c3dc5a 160000 --- a/docs +++ b/docs @@ -1 +1 @@ -Subproject commit 10d5ce9d8e35d5556aa2189a87bb3958561c2ad7 +Subproject commit 52c3dc5a884d81f85d79b912739f4300d1c7d80d diff --git a/platformio/__main__.py b/platformio/__main__.py index d88f69a8..ced8e50a 100644 --- a/platformio/__main__.py +++ b/platformio/__main__.py @@ -26,19 +26,35 @@ from platformio.compat import CYGWIN @click.command(cls=PlatformioCLI, context_settings=dict(help_option_names=["-h", "--help"])) @click.version_option(__version__, prog_name="PlatformIO") -@click.option("--force", - "-f", +@click.option("--force", "-f", is_flag=True, help="DEPRECATE") +@click.option("--caller", "-c", help="Caller ID (service)") +@click.option("--no-ansi", is_flag=True, - help="Force to accept any confirmation prompts.") -@click.option("--caller", "-c", help="Caller ID (service).") + help="Do not print ANSI control characters") @click.pass_context -def cli(ctx, force, caller): +def cli(ctx, force, caller, no_ansi): + try: + if (no_ansi or str( + os.getenv( + "PLATFORMIO_NO_ANSI", + os.getenv("PLATFORMIO_DISABLE_COLOR"))).lower() == "true"): + # pylint: disable=protected-access + click._compat.isatty = lambda stream: False + elif str( + os.getenv( + "PLATFORMIO_FORCE_ANSI", + os.getenv("PLATFORMIO_FORCE_COLOR"))).lower() == "true": + # pylint: disable=protected-access + click._compat.isatty = lambda stream: True + except: # pylint: disable=bare-except + pass + maintenance.on_platformio_start(ctx, force, caller) @cli.resultcallback() @click.pass_context -def process_result(ctx, result, force, caller): # pylint: disable=W0613 +def process_result(ctx, result, *_, **__): maintenance.on_platformio_end(ctx, result) @@ -55,16 +71,6 @@ def configure(): except (AttributeError, ImportError): pass - try: - if str(os.getenv("PLATFORMIO_DISABLE_COLOR", "")).lower() == "true": - # pylint: disable=protected-access - click._compat.isatty = lambda stream: False - elif str(os.getenv("PLATFORMIO_FORCE_COLOR", "")).lower() == "true": - # pylint: disable=protected-access - click._compat.isatty = lambda stream: True - except: # pylint: disable=bare-except - pass - # Handle IOError issue with VSCode's Terminal (Windows) click_echo_origin = [click.echo, click.secho] @@ -87,7 +93,7 @@ def main(argv=None): sys.argv = argv try: configure() - cli(None, None, None) + cli() # pylint: disable=no-value-for-parameter except SystemExit: pass except Exception as e: # pylint: disable=broad-except