From 4fce954f9798f5872f110a93317d945b3496cc0e Mon Sep 17 00:00:00 2001 From: Xavier Claessens Date: Fri, 23 Sep 2022 14:26:06 -0400 Subject: mconf: Use pager only when printing configuration Fixes: #10845 --- mesonbuild/mconf.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/mesonbuild/mconf.py b/mesonbuild/mconf.py index ad00874..ef176d7 100644 --- a/mesonbuild/mconf.py +++ b/mesonbuild/mconf.py @@ -36,7 +36,7 @@ def add_arguments(parser: 'argparse.ArgumentParser') -> None: parser.add_argument('builddir', nargs='?', default='.') parser.add_argument('--clearcache', action='store_true', default=False, help='Clear cached state (e.g. found dependencies)') - parser.add_argument('--no-pager', action='store_true', default=False, + parser.add_argument('--no-pager', action='store_false', dest='pager', help='Do not redirect output to a pager') def make_lower_case(val: T.Any) -> T.Union[str, T.List[T.Any]]: # T.Any because of recursion... @@ -205,7 +205,10 @@ class Conf: printable_value = '' self.add_option(str(root), o.description, printable_value, o.choices) - def print_conf(self): + def print_conf(self, pager: bool): + if pager: + mlog.start_pager() + def print_default_values_warning(): mlog.warning('The source directory instead of the build directory was specified.') mlog.warning('Only the default values for the project are printed, and all command line parameters are ignored.') @@ -297,13 +300,11 @@ class Conf: def run(options): coredata.parse_cmd_line_options(options) builddir = os.path.abspath(os.path.realpath(options.builddir)) - if not options.no_pager: - mlog.start_pager() c = None try: c = Conf(builddir) if c.default_values_only: - c.print_conf() + c.print_conf(options.pager) return 0 save = False @@ -315,7 +316,7 @@ def run(options): c.clear_cache() save = True else: - c.print_conf() + c.print_conf(options.pager) if save: c.save() mintro.update_build_options(c.coredata, c.build.environment.info_dir) -- cgit v1.1