Produce less noisy output when “-s/—silent” options are used for run and init commands // Resolve #850

This commit is contained in:
Ivan Kravets
2016-12-08 14:15:13 +02:00
parent a1ed5c6262
commit ee086ff580
5 changed files with 257 additions and 239 deletions

File diff suppressed because it is too large Load Diff

2
docs

Submodule docs updated: fad663db0c...b75c700805

View File

@ -14,7 +14,7 @@
import sys
VERSION = (3, 2, 1)
VERSION = (3, 2, "2a1")
__version__ = ".".join([str(s) for s in VERSION])
__title__ = "platformio"

View File

@ -57,6 +57,7 @@ def validate_boards(ctx, param, value): # pylint: disable=W0613
"--ide", type=click.Choice(ProjectGenerator.get_supported_ides()))
@click.option("-O", "--project-option", multiple=True)
@click.option("--env-prefix", default="")
@click.option("-s", "--silent", is_flag=True)
@click.pass_context
def cli(
ctx, # pylint: disable=R0913
@ -64,10 +65,13 @@ def cli(
board,
ide,
project_option,
env_prefix):
env_prefix,
silent):
if not silent:
if project_dir == getcwd():
click.secho("\nThe current working directory", fg="yellow", nl=False)
click.secho(
"\nThe current working directory", fg="yellow", nl=False)
click.secho(" %s " % project_dir, fg="cyan", nl=False)
click.secho(
"will be used for project.\n"
@ -111,6 +115,7 @@ def cli(
pg = ProjectGenerator(project_dir, ide, board[0])
pg.generate()
if not silent:
click.secho(
"\nProject has been successfully initialized!\nUseful commands:\n"
"`platformio run` - process/build project from the current "

View File

@ -95,7 +95,7 @@ def cli(ctx, environment, target, upload_port, project_dir, silent, verbose,
results.append((envname, None))
continue
if results:
if not silent and results:
click.echo()
options = {}
@ -108,11 +108,13 @@ def cli(ctx, environment, target, upload_port, project_dir, silent, verbose,
upload_port, silent, verbose)
results.append((envname, ep.process()))
if len(results) > 1:
found_error = any([status is False for (_, status) in results])
if (found_error or not silent) and len(results) > 1:
click.echo()
print_summary(results, start_time)
if any([status is False for (_, status) in results]):
if found_error:
raise exception.ReturnErrorCode(1)
return True
@ -160,18 +162,20 @@ class EnvironmentProcessor(object):
if "\n" in v:
self.options[k] = self.options[k].strip().replace("\n", ", ")
if not self.silent:
click.echo("[%s] Processing %s (%s)" % (
datetime.now().strftime("%c"), click.style(
self.name, fg="cyan", bold=True),
", ".join(["%s: %s" % (k, v) for k, v in self.options.items()])))
self.name, fg="cyan", bold=True), ", ".join(
["%s: %s" % (k, v) for k, v in self.options.items()])))
click.secho("-" * terminal_width, bold=True)
if self.silent:
click.echo("Please wait...")
self.options = self._validate_options(self.options)
result = self._run()
is_error = result['returncode'] != 0
if self.silent and not is_error:
return True
if is_error or "piotest_processor" not in self.cmd_ctx.meta:
print_header(
"[%s] Took %.2f seconds" % ((click.style(