Skip to content

Add --no-timings and --no-status - #1637

Open
DiegoDAF wants to merge 1 commit into
dbcli:mainfrom
DiegoDAF:upstream/no-timings-no-status
Open

DiegoDAF wants to merge 1 commit into
dbcli:mainfrom
DiegoDAF:upstream/no-timings-no-status

Conversation

@DiegoDAF

Copy link
Copy Markdown
Contributor

This is item 11 of #1603.

Description

-t/--tuples-only already turns off the timing line and the status footer, but it also drops the column headers, the title and the table formatting, because it matches psql -t. There is currently no way to keep the table intact and suppress only one of the two footers.

That combination is what scripts tend to want. --no-timings alone keeps the status footer, so a wrapper can still read UPDATE 12 back; --no-status alone keeps the timing line, which is handy when timing a query whose output you are eyeballing. Both are off by default, so nothing changes for anyone who does not pass them.

The two flags are independent of each other and of -t, which keeps working as the shorthand for both:

pgcli -c "select 1 as uno"                 table + SELECT 1 + Time: 0.004s
pgcli --no-timings -c "select 1 as uno"    table + SELECT 1
pgcli --no-status  -c "select 1 as uno"    table + Time: 0.004s
pgcli --no-timings --no-status -c "..."    table
pgcli -t -c "select 1 as uno"              1

Implementation is small: --no-timings reuses the pgspecial.timing_enabled switch that -t already flips, and --no-status adds a show_status field to OutputSettings that format_output() checks next to the existing tuples_only check.

8 tests. Two of them fail if the flags are wired to -t rather than standing on their own, which was the mistake worth pinning down.

Checklist

  • I have added this contribution to the changelog.rst.
  • I have added my name to the AUTHORS file (or it is already there).
  • I installed pre-commit hooks (pip install pre-commit && pre-commit install).
  • Please squash merge this pull request (uncheck if you would like us to merge as multiple commits)

On the third box: .pre-commit-config.yaml pins ruff-pre-commit at v0.11.7 while tox -e style installs ruff unpinned (0.15.x today), and the two disagree on formatting, so the hook reformats code that the style job then wants reformatted back. I ran ruff check and ruff format matching the CI instead, both clean.

-t/--tuples-only already turns off the timing line and the status
footer, but it also drops the headers, the title and the table
formatting. Scripts that post-process pgcli output often want the table
intact and only one of the two footers gone, and there was no way to
ask for that.

The two flags are independent of each other and of -t, which keeps
working as the psql-compatible shorthand for both.

8 tests, 2 of which fail if the flags are wired to -t instead of
standing on their own.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant