mirror of
https://github.com/platformio/platformio-core.git
synced 2025-07-30 10:07:14 +02:00
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
|
import sys
|
||||||
|
|
||||||
VERSION = (3, 2, 1)
|
VERSION = (3, 2, "2a1")
|
||||||
__version__ = ".".join([str(s) for s in VERSION])
|
__version__ = ".".join([str(s) for s in VERSION])
|
||||||
|
|
||||||
__title__ = "platformio"
|
__title__ = "platformio"
|
||||||
|
@ -57,6 +57,7 @@ def validate_boards(ctx, param, value): # pylint: disable=W0613
|
|||||||
"--ide", type=click.Choice(ProjectGenerator.get_supported_ides()))
|
"--ide", type=click.Choice(ProjectGenerator.get_supported_ides()))
|
||||||
@click.option("-O", "--project-option", multiple=True)
|
@click.option("-O", "--project-option", multiple=True)
|
||||||
@click.option("--env-prefix", default="")
|
@click.option("--env-prefix", default="")
|
||||||
|
@click.option("-s", "--silent", is_flag=True)
|
||||||
@click.pass_context
|
@click.pass_context
|
||||||
def cli(
|
def cli(
|
||||||
ctx, # pylint: disable=R0913
|
ctx, # pylint: disable=R0913
|
||||||
@ -64,28 +65,31 @@ def cli(
|
|||||||
board,
|
board,
|
||||||
ide,
|
ide,
|
||||||
project_option,
|
project_option,
|
||||||
env_prefix):
|
env_prefix,
|
||||||
|
silent):
|
||||||
|
|
||||||
if project_dir == getcwd():
|
if not silent:
|
||||||
click.secho("\nThe current working directory", fg="yellow", nl=False)
|
if project_dir == getcwd():
|
||||||
click.secho(" %s " % project_dir, fg="cyan", nl=False)
|
click.secho(
|
||||||
click.secho(
|
"\nThe current working directory", fg="yellow", nl=False)
|
||||||
"will be used for project.\n"
|
click.secho(" %s " % project_dir, fg="cyan", nl=False)
|
||||||
"You can specify another project directory via\n"
|
click.secho(
|
||||||
"`platformio init -d %PATH_TO_THE_PROJECT_DIR%` command.",
|
"will be used for project.\n"
|
||||||
fg="yellow")
|
"You can specify another project directory via\n"
|
||||||
click.echo("")
|
"`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.echo("The next files/directories have been created in %s" %
|
||||||
click.style(
|
click.style(
|
||||||
project_dir, fg="cyan"))
|
project_dir, fg="cyan"))
|
||||||
click.echo("%s - Project Configuration File" % click.style(
|
click.echo("%s - Project Configuration File" % click.style(
|
||||||
"platformio.ini", fg="cyan"))
|
"platformio.ini", fg="cyan"))
|
||||||
click.echo("%s - Put your source files here" % click.style(
|
click.echo("%s - Put your source files here" % click.style(
|
||||||
"src", fg="cyan"))
|
"src", fg="cyan"))
|
||||||
click.echo("%s - Put here project specific (private) libraries" %
|
click.echo("%s - Put here project specific (private) libraries" %
|
||||||
click.style(
|
click.style(
|
||||||
"lib", fg="cyan"))
|
"lib", fg="cyan"))
|
||||||
|
|
||||||
init_base_project(project_dir)
|
init_base_project(project_dir)
|
||||||
|
|
||||||
@ -111,16 +115,17 @@ def cli(
|
|||||||
pg = ProjectGenerator(project_dir, ide, board[0])
|
pg = ProjectGenerator(project_dir, ide, board[0])
|
||||||
pg.generate()
|
pg.generate()
|
||||||
|
|
||||||
click.secho(
|
if not silent:
|
||||||
"\nProject has been successfully initialized!\nUseful commands:\n"
|
click.secho(
|
||||||
"`platformio run` - process/build project from the current "
|
"\nProject has been successfully initialized!\nUseful commands:\n"
|
||||||
"directory\n"
|
"`platformio run` - process/build project from the current "
|
||||||
"`platformio run --target upload` or `platformio run -t upload` "
|
"directory\n"
|
||||||
"- upload firmware to embedded board\n"
|
"`platformio run --target upload` or `platformio run -t upload` "
|
||||||
"`platformio run --target clean` - clean project (remove compiled "
|
"- upload firmware to embedded board\n"
|
||||||
"files)\n"
|
"`platformio run --target clean` - clean project (remove compiled "
|
||||||
"`platformio run --help` - additional information",
|
"files)\n"
|
||||||
fg="green")
|
"`platformio run --help` - additional information",
|
||||||
|
fg="green")
|
||||||
|
|
||||||
|
|
||||||
def get_first_board(project_dir):
|
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))
|
results.append((envname, None))
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if results:
|
if not silent and results:
|
||||||
click.echo()
|
click.echo()
|
||||||
|
|
||||||
options = {}
|
options = {}
|
||||||
@ -108,11 +108,13 @@ def cli(ctx, environment, target, upload_port, project_dir, silent, verbose,
|
|||||||
upload_port, silent, verbose)
|
upload_port, silent, verbose)
|
||||||
results.append((envname, ep.process()))
|
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()
|
click.echo()
|
||||||
print_summary(results, start_time)
|
print_summary(results, start_time)
|
||||||
|
|
||||||
if any([status is False for (_, status) in results]):
|
if found_error:
|
||||||
raise exception.ReturnErrorCode(1)
|
raise exception.ReturnErrorCode(1)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@ -160,18 +162,20 @@ class EnvironmentProcessor(object):
|
|||||||
if "\n" in v:
|
if "\n" in v:
|
||||||
self.options[k] = self.options[k].strip().replace("\n", ", ")
|
self.options[k] = self.options[k].strip().replace("\n", ", ")
|
||||||
|
|
||||||
click.echo("[%s] Processing %s (%s)" % (
|
if not self.silent:
|
||||||
datetime.now().strftime("%c"), click.style(
|
click.echo("[%s] Processing %s (%s)" % (
|
||||||
self.name, fg="cyan", bold=True),
|
datetime.now().strftime("%c"), click.style(
|
||||||
", ".join(["%s: %s" % (k, v) for k, v in self.options.items()])))
|
self.name, fg="cyan", bold=True), ", ".join(
|
||||||
click.secho("-" * terminal_width, bold=True)
|
["%s: %s" % (k, v) for k, v in self.options.items()])))
|
||||||
if self.silent:
|
click.secho("-" * terminal_width, bold=True)
|
||||||
click.echo("Please wait...")
|
|
||||||
|
|
||||||
self.options = self._validate_options(self.options)
|
self.options = self._validate_options(self.options)
|
||||||
result = self._run()
|
result = self._run()
|
||||||
|
|
||||||
is_error = result['returncode'] != 0
|
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:
|
if is_error or "piotest_processor" not in self.cmd_ctx.meta:
|
||||||
print_header(
|
print_header(
|
||||||
"[%s] Took %.2f seconds" % ((click.style(
|
"[%s] Took %.2f seconds" % ((click.style(
|
||||||
|
Reference in New Issue
Block a user