Skip to content

fix(sheets): respect --plain flag for TSV output in metadata command#298

Merged
steipete merged 2 commits intosteipete:mainfrom
mahsumaktas:fix/sheets-plain-tsv-209
Mar 7, 2026
Merged

fix(sheets): respect --plain flag for TSV output in metadata command#298
steipete merged 2 commits intosteipete:mainfrom
mahsumaktas:fix/sheets-plain-tsv-209

Conversation

@mahsumaktas
Copy link
Copy Markdown
Contributor

Summary

Fix sheets metadata --plain to output real tab-delimited values instead of space-padded columns. Also fixes a type mismatch build error in contacts_crud.go.

Problem

The sheets metadata command used tabwriter.NewWriter directly instead of the tableWriter(ctx) helper. The helper already checks outfmt.IsPlain(ctx) and bypasses tabwriter when --plain is set — but metadata was not using it.

This caused --plain output to have space-padded columns instead of real \t delimiters, breaking piping to tools like cut, awk, or csvtool that expect TSV.

# Before (spaces, not tabs):
ID   TITLE    ROWS  COLS
1    Sheet1   10    5

# After (real tabs):
ID⟶TITLE⟶ROWS⟶COLS
1⟶Sheet1⟶10⟶5

Changes

File Change
internal/cmd/sheets.go Replace direct tabwriter.NewWriter with tableWriter(ctx) in SheetsMetadataCmd; remove unused text/tabwriter import
internal/cmd/contacts_crud.go Fix type mismatch: add explicit string type to given and org parameters in helper functions
internal/cmd/sheets_plain_test.go Add 2 tests verifying tab delimiters in --plain mode for both sheets get and sheets metadata

Testing

go test ./internal/cmd/ -run "TestSheets" -v
# All 11 tests pass (9 existing + 2 new)

Related Issues

mahsumaktas and others added 2 commits March 7, 2026 23:22
…V output

The `sheets metadata` command was using `tabwriter.NewWriter` directly
instead of the `tableWriter` helper, which converts tab characters to
spaces for visual alignment. This broke `--plain` mode, which documents
stable TSV output for piping to external tools.

Changes:
- Replace direct `tabwriter.NewWriter` in `SheetsMetadataCmd` with
  `tableWriter(ctx)` helper (which already respects `IsPlain`)
- Remove unused `text/tabwriter` import from sheets.go
- Fix type mismatch in `contactsApplyPersonName` and
  `contactsApplyPersonOrganization` function signatures (#285)
- Add tests for plain TSV output in both `sheets get` and
  `sheets metadata` commands

Fixes #209
Fixes #285
@steipete steipete force-pushed the fix/sheets-plain-tsv-209 branch from 64563cf to 057cbc7 Compare March 7, 2026 23:23
@steipete steipete merged commit b6c5c79 into steipete:main Mar 7, 2026
1 check passed
@steipete
Copy link
Copy Markdown
Owner

steipete commented Mar 7, 2026

Landed via temp rebase onto main.

Thanks @mahsumaktas!

klodr pushed a commit to klodr/gogcli that referenced this pull request Apr 22, 2026
…teipete#298)

* fix(sheets): use tableWriter helper in metadata to respect --plain TSV output

The `sheets metadata` command was using `tabwriter.NewWriter` directly
instead of the `tableWriter` helper, which converts tab characters to
spaces for visual alignment. This broke `--plain` mode, which documents
stable TSV output for piping to external tools.

Changes:
- Replace direct `tabwriter.NewWriter` in `SheetsMetadataCmd` with
  `tableWriter(ctx)` helper (which already respects `IsPlain`)
- Remove unused `text/tabwriter` import from sheets.go
- Fix type mismatch in `contactsApplyPersonName` and
  `contactsApplyPersonOrganization` function signatures (steipete#285)
- Add tests for plain TSV output in both `sheets get` and
  `sheets metadata` commands

Fixes steipete#209
Fixes steipete#285

* fix(sheets): respect plain TSV output in metadata (steipete#298) (thanks @mahsumaktas)

---------

Co-authored-by: Peter Steinberger <steipete@gmail.com>
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.

Type Mismatch Errors in internal/cmd/contacts_crud.go sheets get --plain outputs spaces instead of tabs

2 participants