diff options
author | Amjith Ramanujam <amjith@newrelic.com> | 2014-12-19 20:57:36 -0800 |
---|---|---|
committer | Amjith Ramanujam <amjith@newrelic.com> | 2014-12-19 20:57:36 -0800 |
commit | c66f9a79e1ff98f123018305cabe22732a33b1b2 (patch) | |
tree | 6f89f40d8e0224d01fe9c82a0364b21415808392 | |
parent | ca36dba63a43cfcbd605d1e6fd3810f664ca1f7b (diff) |
Add pager support for output.
-rw-r--r-- | TODO | 3 | ||||
-rwxr-xr-x | pgcli/main.py | 6 |
2 files changed, 6 insertions, 3 deletions
@@ -1,6 +1,6 @@ # vi: ft=vimwiki * [ ] Fix: SELECT id, <tab> FROM django_migrations; - Auto-completion for the second column name is broken. Find the last keyword and use it for completion. -* [ ] Use a pager to display the output. (Check Click's document). +* [ ] Bottom status bar is cut-off in half pane. Figure out how to fix that. * [ ] Default host should not be set to localhost. Since it causes problems in IPv6 machines. Need to research this one further. * [ ] Column completion for nested sql. * [ ] Add JOIN to the list of keywords and provide proper autocompletion for it. @@ -27,6 +27,7 @@ * [ ] New Feature List - Write the current version to config file. At launch if the version has changed, display the changelog between the two versions. * [o] Separate the column completions to be table specific. (SELECT, INSERT, UPDATE) * [X] Write a doc about how to run it in develop mode. (pip install -e .) +* [X] Use a pager to display the output. (Check Click's document). * [X] Column completion for simple SELECT. * [X] Column completion for simple INSERT. * [X] Column completion for simple UPDATE. diff --git a/pgcli/main.py b/pgcli/main.py index db1f9001..ce4c4560 100755 --- a/pgcli/main.py +++ b/pgcli/main.py @@ -87,11 +87,13 @@ def cli(database, user, password, host, port): raise Exit try: res = pgexecute.run(document.text) + output = [] for rows, headers, status in res: if rows: - print(tabulate(rows, headers, tablefmt='psql')) + output.append(tabulate(rows, headers, tablefmt='psql')) if status: # Only print the status if it's not None. - print(status) + output.append(status) + click.echo_via_pager('\n'.join(output)) except Exception as e: click.secho(e.message, err=True, fg='red') |