You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@buildstream.apache.org by ro...@apache.org on 2020/12/29 13:32:34 UTC

[buildstream] branch quiet-output created (now 3b7f566)

This is an automated email from the ASF dual-hosted git repository.

root pushed a change to branch quiet-output
in repository https://gitbox.apache.org/repos/asf/buildstream.git.


      at 3b7f566  frontend/main: Add a --quiet option

This branch includes the following new commits:

     new 3b7f566  frontend/main: Add a --quiet option

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[buildstream] 01/01: frontend/main: Add a --quiet option

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

root pushed a commit to branch quiet-output
in repository https://gitbox.apache.org/repos/asf/buildstream.git

commit 3b7f566d9763c941fe500db7e25d4f46d6c8e7be
Author: Mathieu Bridon <bo...@daitauha.fr>
AuthorDate: Tue Dec 12 23:30:43 2017 +0100

    frontend/main: Add a --quiet option
    
    This drops all status output from BuildStream, except error messages.
    
    It is especially useful when running commands in a `bst shell` and
    needing to redirect their output, without getting the BuildStream output
    with it.
---
 buildstream/_frontend/main.py    | 22 ++++++++++++++++++++++
 tests/completions/completions.py |  1 +
 2 files changed, 23 insertions(+)

diff --git a/buildstream/_frontend/main.py b/buildstream/_frontend/main.py
index 117d148..b9b4b16 100644
--- a/buildstream/_frontend/main.py
+++ b/buildstream/_frontend/main.py
@@ -162,6 +162,8 @@ click.BaseCommand.main = override_main
               help="Force non interactive mode, otherwise this is automatically decided")
 @click.option('--verbose/--no-verbose', default=None,
               help="Be extra verbose")
+@click.option('--quiet', is_flag=True, default=False,
+              help="Be extra quiet")
 @click.option('--debug/--no-debug', default=None,
               help="Print debugging output")
 @click.option('--error-lines', type=click.INT, default=None,
@@ -769,6 +771,11 @@ class App():
         # defaults to whether we are interactive or not.
         self.interactive_failures = self.interactive
 
+        self.quiet = self.main_options['quiet']
+        if self.quiet and (self.main_options['debug'] or self.main_options['verbose']):
+            click.echo("ERROR: Option --quiet cannot be used with --debug or --verbose", err=True)
+            sys.exit(-1)
+
         # Resolve whether to use colors in output
         if self.main_options['colors'] is None:
             self.colors = self.is_a_tty
@@ -795,6 +802,11 @@ class App():
             click.echo("Error loading user configuration: {}".format(e), err=True)
             sys.exit(-1)
 
+        if self.quiet:
+            # We really want those set to False, not to the defaults from user config
+            self.main_options['debug'] = False
+            self.main_options['verbose'] = False
+
         # Override things in the context from our command line options,
         # the command line when used, trumps the config files.
         #
@@ -875,6 +887,8 @@ class App():
     # Render the status area, conditional on some internal state
     #
     def maybe_render_status(self):
+        if self.quiet:
+            return
 
         # If we're suspended or terminating, then dont render the status area
         if self.status and self.scheduler and \
@@ -1030,6 +1044,9 @@ class App():
     # will process a pipeline.
     #
     def print_heading(self, deps=None):
+        if self.quiet:
+            return
+
         self.logger.print_heading(self.pipeline,
                                   self.main_options['log_file'],
                                   styling=self.colors,
@@ -1039,6 +1056,9 @@ class App():
     # Print a summary of the queues
     #
     def print_summary(self):
+        if self.quiet:
+            return
+
         self.logger.print_summary(self.pipeline, self.scheduler,
                                   self.main_options['log_file'],
                                   styling=self.colors)
@@ -1047,6 +1067,8 @@ class App():
     # Handle messages from the pipeline
     #
     def message_handler(self, message, context):
+        if self.quiet and message.message_type not in (MessageType.FAIL, MessageType.BUG):
+            return
 
         # Drop status messages from the UI if not verbose, we'll still see
         # info messages and status messages will still go to the log files.
diff --git a/tests/completions/completions.py b/tests/completions/completions.py
index 8ecf83e..25f5a11 100644
--- a/tests/completions/completions.py
+++ b/tests/completions/completions.py
@@ -40,6 +40,7 @@ MAIN_OPTIONS = [
     "--option ",
     "--on-error ",
     "--pushers ",
+    "--quiet ",
     "--strict ",
     "--verbose ",
     "--version ",