fix(cli): honor --no-headers flag with --fmt/--table output#729
Open
CrepuscularIRIS wants to merge 1 commit intosimonw:mainfrom
Open
fix(cli): honor --no-headers flag with --fmt/--table output#729CrepuscularIRIS wants to merge 1 commit intosimonw:mainfrom
CrepuscularIRIS wants to merge 1 commit intosimonw:mainfrom
Conversation
Fixes simonw#566 The --no-headers flag was only checked in the CSV/TSV output branch. When --fmt or --table was used, tabulate.tabulate() was always called with headers=headers, ignoring the flag. Pass headers=() instead when no_headers is set, which suppresses header display while preserving table formatting.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #566
The
--no-headersflag was silently ignored when combined with--fmtor--table. Headers appeared in the output regardless.Root Cause
The
--no-headersflag was only checked in the CSV/TSV output branch (line 243). When--fmtor--tablewas used,tabulate.tabulate()was always called withheaders=headers, bypassing the flag entirely. This affected both thetablescommand (line 240) and thequery/_execute_querypath (line 2148).Changes
sqlite_utils/cli.py: Passheaders=() if no_headers else headersto bothtabulate.tabulate()call sites.tabulatenatively supportsheaders=()for suppressing header display.tests/test_cli.py: Addedtest_output_table_no_headers(parametrized overplainandsimpleformats) andtest_query_fmt_no_headers(verifies thequerycommand path).Testing
Notes
Chose to make
--no-headerswork with--fmtrather than raising an error, sincetabulatesupports headerless output cleanly viaheaders=(). This keeps--no-headersconsistent across all output modes (CSV, TSV, and tabulate formats).📚 Documentation preview 📚: https://sqlite-utils--729.org.readthedocs.build/en/729/