1
1
mirror of https://github.com/dbcli/pgcli.git synced 2024-10-06 10:17:15 +03:00

Add pager support for output.

This commit is contained in:
Amjith Ramanujam 2014-12-19 20:57:36 -08:00
parent ca36dba63a
commit c66f9a79e1
2 changed files with 6 additions and 3 deletions

3
TODO
View File

@ -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.

View File

@ -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')