forked from platformio/platformio-core
Produce less noisy output when “-s/—silent” options are used for run and init commands // Resolve #850
This commit is contained in:
401
HISTORY.rst
401
HISTORY.rst
File diff suppressed because it is too large
Load Diff
2
docs
2
docs
Submodule docs updated: fad663db0c...b75c700805
@ -14,7 +14,7 @@
|
||||
|
||||
import sys
|
||||
|
||||
VERSION = (3, 2, 1)
|
||||
VERSION = (3, 2, "2a1")
|
||||
__version__ = ".".join([str(s) for s in VERSION])
|
||||
|
||||
__title__ = "platformio"
|
||||
|
@ -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,28 +65,31 @@ def cli(
|
||||
board,
|
||||
ide,
|
||||
project_option,
|
||||
env_prefix):
|
||||
env_prefix,
|
||||
silent):
|
||||
|
||||
if project_dir == getcwd():
|
||||
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"
|
||||
"You can specify another project directory via\n"
|
||||
"`platformio init -d %PATH_TO_THE_PROJECT_DIR%` command.",
|
||||
fg="yellow")
|
||||
click.echo("")
|
||||
if not silent:
|
||||
if project_dir == getcwd():
|
||||
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"
|
||||
"You can specify another project directory via\n"
|
||||
"`platformio init -d %PATH_TO_THE_PROJECT_DIR%` command.",
|
||||
fg="yellow")
|
||||
click.echo("")
|
||||
|
||||
click.echo("The next files/directories have been created in %s" %
|
||||
click.style(
|
||||
project_dir, fg="cyan"))
|
||||
click.echo("%s - Project Configuration File" % click.style(
|
||||
"platformio.ini", fg="cyan"))
|
||||
click.echo("%s - Put your source files here" % click.style(
|
||||
"src", fg="cyan"))
|
||||
click.echo("%s - Put here project specific (private) libraries" %
|
||||
click.style(
|
||||
"lib", fg="cyan"))
|
||||
click.echo("The next files/directories have been created in %s" %
|
||||
click.style(
|
||||
project_dir, fg="cyan"))
|
||||
click.echo("%s - Project Configuration File" % click.style(
|
||||
"platformio.ini", fg="cyan"))
|
||||
click.echo("%s - Put your source files here" % click.style(
|
||||
"src", fg="cyan"))
|
||||
click.echo("%s - Put here project specific (private) libraries" %
|
||||
click.style(
|
||||
"lib", fg="cyan"))
|
||||
|
||||
init_base_project(project_dir)
|
||||
|
||||
@ -111,16 +115,17 @@ def cli(
|
||||
pg = ProjectGenerator(project_dir, ide, board[0])
|
||||
pg.generate()
|
||||
|
||||
click.secho(
|
||||
"\nProject has been successfully initialized!\nUseful commands:\n"
|
||||
"`platformio run` - process/build project from the current "
|
||||
"directory\n"
|
||||
"`platformio run --target upload` or `platformio run -t upload` "
|
||||
"- upload firmware to embedded board\n"
|
||||
"`platformio run --target clean` - clean project (remove compiled "
|
||||
"files)\n"
|
||||
"`platformio run --help` - additional information",
|
||||
fg="green")
|
||||
if not silent:
|
||||
click.secho(
|
||||
"\nProject has been successfully initialized!\nUseful commands:\n"
|
||||
"`platformio run` - process/build project from the current "
|
||||
"directory\n"
|
||||
"`platformio run --target upload` or `platformio run -t upload` "
|
||||
"- upload firmware to embedded board\n"
|
||||
"`platformio run --target clean` - clean project (remove compiled "
|
||||
"files)\n"
|
||||
"`platformio run --help` - additional information",
|
||||
fg="green")
|
||||
|
||||
|
||||
def get_first_board(project_dir):
|
||||
|
@ -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", ", ")
|
||||
|
||||
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()])))
|
||||
click.secho("-" * terminal_width, bold=True)
|
||||
if self.silent:
|
||||
click.echo("Please wait...")
|
||||
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()])))
|
||||
click.secho("-" * terminal_width, bold=True)
|
||||
|
||||
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(
|
||||
|
Reference in New Issue
Block a user