From f836c3a3a4164fe7d2561f8f62f87bb8aab0b8fc Mon Sep 17 00:00:00 2001 From: Jason Ribeiro Date: Mon, 14 May 2018 14:20:37 -0400 Subject: [PATCH] Disable pager when using \watch --- changelog.rst | 4 ++++ pgcli/main.py | 12 ++++++------ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/changelog.rst b/changelog.rst index 1779446b..4a935c3c 100644 --- a/changelog.rst +++ b/changelog.rst @@ -11,6 +11,10 @@ Internal changes: * Mark tests requiring a running database server as dbtest (Thanks: `Dick Marinus`_) * Add ``application_name`` to help identify pgcli connection to database (issue #868) (Thanks: `François Pietka`_) +Bug Fixes: +---------- +* Disable pager when using \watch (#837). (Thanks: `Jason Ribeiro`_) + 1.9.1: ====== diff --git a/pgcli/main.py b/pgcli/main.py index c7075cd9..98c4fef1 100644 --- a/pgcli/main.py +++ b/pgcli/main.py @@ -564,15 +564,15 @@ class PGCli(object): # Initialize default metaquery in case execution fails query = MetaQuery(query=document.text, successful=False) - watch_command, timing = special.get_watch_command(document.text) - if watch_command: - while watch_command: + self.watch_command, timing = special.get_watch_command(document.text) + if self.watch_command: + while self.watch_command: try: - query = self.execute_command(watch_command, query) + query = self.execute_command(self.watch_command, query) click.echo('Waiting for {0} seconds before repeating'.format(timing)) sleep(timing) except KeyboardInterrupt: - watch_command = None + self.watch_command = None else: query = self.execute_command(document.text, query) @@ -840,7 +840,7 @@ class PGCli(object): return self.query_history[-1][0] if self.query_history else None def echo_via_pager(self, text, color=None): - if self.pgspecial.pager_config == PAGER_OFF: + if self.pgspecial.pager_config == PAGER_OFF or self.watch_command: click.echo(text, color=color) else: click.echo_via_pager(text, color)