New "--no-ansi" flag for PIO Core

This commit is contained in:
Ivan Kravets committed 2019-09-23 20:51:02 +03:00
1 parent cd8dc24454
commit 61b6eea52c
3 files changed
+25 -18

No files matched your search

+23 -17
View File
@@ -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