Add support for -t/--tuples-only option to print rows without extra output#1545
Add support for -t/--tuples-only option to print rows without extra output#1545DiegoDAF wants to merge 3 commits into
Conversation
|
Thank you for the PR! I have some problems with it, for two reasons:
This does not solve your header / status suppression requirement, but I think that should be a separate change. Perhaps pgcli should be aware of |
|
Thanks for the feedback, makes total sense! I'll rework this PR so that The |
5ca0788 to
3d86709
Compare
Made with ❤️ and 🤖 Claude
|
This has conflicts. |
3d86709 to
e1cf78c
Compare
…ression Simplified per reviewer feedback (j-bennet): - `-t` is now a pure boolean flag (no format argument) - Sets table_format to csv-noheader at startup (like `\T csv-noheader`) - Does NOT suppress timing or status messages - Removed tuples_only from OutputSettings namedtuple - For custom formats, use `\T FORMAT` interactively Made with ❤️ and 🤖 Claude
e1cf78c to
8756bfe
Compare
Spurious reformat introduced during rebase; ruff 0.15.11 with preview=true keeps the original split form. Restores upstream layout.
# Conflicts: # changelog.rst
|
Reworked per your feedback: |
|
Hey @j-bennet! 🎉 Congrats on shipping 4.5.0, and thank you so much for merging #1559, really made my week! While you are in release mode, would you have a moment to peek at this one too? It is rebased and green now that the CI env vars are back. Totally understand if you are swamped, no pressure at all. Thanks again for everything you do for pgcli! 🙏 |
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: fe47a48c8f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if tuples_only: | ||
| self.table_format = "csv-noheader" |
There was a problem hiding this comment.
Honor tuples-only by suppressing extra output
When -t/--tuples-only is used, this branch only switches the formatter to csv-noheader; the output path still appends command status in format_output (pgcli/main.py:1968-1970) and prints timing whenever enabled (pgcli/main.py:901, with the default config setting timing = True). PostgreSQL documents --tuples-only as turning off column names and row-count footers, so with the default config a query still emits SELECT n and Time: ..., which breaks users relying on this option for rows-only output. Please carry the tuples-only state through to suppress status/timing, or avoid exposing it as psql-style tuples-only.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Thanks @codex, fair point on the psql semantics. This is intentional for this PR: -t was deliberately narrowed during review to be a startup shortcut for the output format only (like a CLI \T), not psql's full tuples-only. Suppressing the status footer and timing is kept to separate, composable flags (--no-timings / --no-status) rather than bundled into -t, so each concern stays granular. So the scope here is "format shortcut", and rows-only-with-no-footers is achieved by combining flags. Open to revisiting the naming if -t/--tuples-only reads as too psql-flavored for that scope.
There was a problem hiding this comment.
To use Codex here, create an environment for this repo.
Summary
This PR implements the
-t/--tuples-onlyoption, similar to psql's-tflag, which prints query results without status messages or timing information. This is useful for scripting and piping output to other commands.Features
pgcli -toutputs rows in CSV format without headerspgcli -t minimalallows specifying any table formatUse Cases
Implementation Details
tuples_onlyfield toOutputSettingsnamedtupletuples_onlyparameter toPGCli.__init__()format_output()to skip status whentuples_only=Truetuples_onlyflagis_flag=Falsewithflag_value="csv-noheader"-talone defaults to csv-noheader-t <format>allows custom formatsCompatibility
Made with ❤️ and 🤖 Claude Code