Commit e4afba8
committed
Add support for -t/--tuples-only option to print rows without extra output
This commit implements a new --tuples-only option similar to psql's -t flag,
which prints query results without status messages or timing information.
Features:
- `-t` or `--tuples-only` without value defaults to csv-noheader format
- `-t <format>` allows specifying any table format (e.g., `-t minimal`)
- Suppresses "SELECT X" status messages when enabled
- Suppresses "Time: X.XXXs" timing output when enabled
- Does not affect normal output when option is not used
Implementation details:
- Added `tuples_only` parameter to PGCli.__init__()
- Added `tuples_only` field to OutputSettings namedtuple
- Modified format_output() to skip status when tuples_only is True
- Modified timing output logic to skip when tuples_only is True
- Preserves all existing functionality when flag is not used
Example usage:
pgcli -t -c "SELECT oid FROM pg_roles WHERE rolname='user';"
# Output: 2124219 (nothing else)
pgcli -t minimal -c "SELECT oid, rolname FROM pg_roles LIMIT 3;"
# Output: aligned columns without headers or status
Made with ❤️ and 🤖 Claude Code1 parent 1723391 commit e4afba8
2 files changed
+31
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
12 | 18 | | |
13 | 19 | | |
14 | 20 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
117 | 117 | | |
118 | 118 | | |
119 | 119 | | |
120 | | - | |
| 120 | + | |
121 | 121 | | |
122 | 122 | | |
123 | 123 | | |
| |||
130 | 130 | | |
131 | 131 | | |
132 | 132 | | |
| 133 | + | |
133 | 134 | | |
134 | 135 | | |
135 | 136 | | |
| |||
179 | 180 | | |
180 | 181 | | |
181 | 182 | | |
| 183 | + | |
182 | 184 | | |
183 | 185 | | |
184 | 186 | | |
| |||
235 | 237 | | |
236 | 238 | | |
237 | 239 | | |
238 | | - | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
239 | 247 | | |
240 | 248 | | |
241 | 249 | | |
| |||
850 | 858 | | |
851 | 859 | | |
852 | 860 | | |
853 | | - | |
| 861 | + | |
854 | 862 | | |
855 | 863 | | |
856 | 864 | | |
| |||
1135 | 1143 | | |
1136 | 1144 | | |
1137 | 1145 | | |
| 1146 | + | |
1138 | 1147 | | |
1139 | 1148 | | |
1140 | 1149 | | |
| |||
1381 | 1390 | | |
1382 | 1391 | | |
1383 | 1392 | | |
| 1393 | + | |
| 1394 | + | |
| 1395 | + | |
| 1396 | + | |
| 1397 | + | |
| 1398 | + | |
| 1399 | + | |
| 1400 | + | |
| 1401 | + | |
1384 | 1402 | | |
1385 | 1403 | | |
1386 | 1404 | | |
| |||
1444 | 1462 | | |
1445 | 1463 | | |
1446 | 1464 | | |
| 1465 | + | |
1447 | 1466 | | |
1448 | 1467 | | |
1449 | 1468 | | |
| |||
1506 | 1525 | | |
1507 | 1526 | | |
1508 | 1527 | | |
| 1528 | + | |
1509 | 1529 | | |
1510 | 1530 | | |
1511 | 1531 | | |
| |||
1893 | 1913 | | |
1894 | 1914 | | |
1895 | 1915 | | |
1896 | | - | |
1897 | | - | |
| 1916 | + | |
| 1917 | + | |
1898 | 1918 | | |
1899 | 1919 | | |
1900 | 1920 | | |
| |||
0 commit comments