Skip to content

feat(ls): add --format=table with aligned columns#6

Merged
Sanjays2402 merged 1 commit into
mainfrom
feat/ls-table
May 17, 2026
Merged

feat(ls): add --format=table with aligned columns#6
Sanjays2402 merged 1 commit into
mainfrom
feat/ls-table

Conversation

@Sanjays2402

Copy link
Copy Markdown
Owner

tsk ls previously printed ad-hoc lines that were hard to scan once you had more than a few tasks. This PR adds a proper table renderer.

Before

[ ] #1 Ship table format PR  (high)  #dev #priority
[ ] #2 Buy groceries  (low)  #home
[ ] #3 Review long openclaw feedback when it arrives someday  (medium)

After (tsk ls --format table)

ID  DONE  P  DUE  TITLE                                     TAGS
#1  [ ]   H       Ship table format PR                      #dev #priority
#2  [ ]   L       Buy groceries                             #home
#3  [ ]   M       Review long openclaw feedback when it a…

Flags

  • --format plain (default) — keep the existing ad-hoc output
  • --format table — aligned columns
  • --format json — same as --json
  • --json — preserved as a shortcut, equivalent to --format=json
  • --format and --json together → clear error

Implementation

  • Column widths computed from data + headers
  • Title column capped at 40 runes with truncation
  • Unicode-safe width calc (rune count, not byte count)
  • Empty list still prints no tasks

Tests

7 new cases in ls_format_test.go:

  • Header + per-task row presence with checkbox markers
  • --json legacy shortcut still works
  • --format=json matches --json
  • --format=xml → clear "unknown --format" error
  • --format=table --json → mutually exclusive error
  • Long title truncates with ellipsis
  • Empty store still shows "no tasks" in table mode

All green with -race across the full suite.

Part 2/10 of the v0.3.0 improvement series. Follows #5.

`tsk ls` previously printed ad-hoc lines that were hard to scan once you
had more than ~5 tasks. Add a proper table renderer with fixed columns:

  ID  DONE  P  DUE         TITLE                 TAGS
  #1  [ ]   H  2026-05-01  Ship table format PR  #dev

Implementation:
  - New --format flag accepts plain (default), table, or json
  - --json preserved as a shortcut for --format=json
  - --format and --json are mutually exclusive (clear error)
  - Column widths computed from data, header always shown
  - Title capped at 40 runes with ellipsis on overflow
  - Unicode-safe width calc (rune count, not byte count)

Tests: 7 new cases covering header, rows, truncation, empty list,
JSON parity, and flag validation. All green with -race.
@Sanjays2402 Sanjays2402 merged commit 596a752 into main May 17, 2026
4 checks passed
@Sanjays2402 Sanjays2402 deleted the feat/ls-table branch May 17, 2026 03:34
Sanjays2402 added a commit that referenced this pull request May 17, 2026
The TUI has had instant fuzzy search since v0.1. The CLI has been blind:
once a project has >20 tasks, finding one means scrolling `ls` output
manually. This adds the same search affordance to scripts and one-shots.

Implementation:
  - Reuses internal/util/fuzzy (sahilm/fuzzy), same scoring as the TUI
  - Default index: title + #tags + notes
  - --title-only restricts to titles
  - Filter: undone by default, --done | --all
  - --limit N caps results
  - --format plain/table/json (table reuses #6 renderer)
  - --json shortcut preserved, mutually exclusive with --format
  - Empty result: "no matches for <q>" in text, "[]" in JSON

Examples:
  tsk search milk
  tsk search "fix login" --limit 5
  tsk search dev --all
  tsk search docs --json | jq

Tests: 10 cases — title match, tag match, --title-only, done filter,
--all, --limit, --json non-empty, --json empty array, empty query
rejection, table format. All green with -race.
Sanjays2402 added a commit that referenced this pull request May 17, 2026
* feat(search): add `tsk search <query>` for fuzzy CLI search

The TUI has had instant fuzzy search since v0.1. The CLI has been blind:
once a project has >20 tasks, finding one means scrolling `ls` output
manually. This adds the same search affordance to scripts and one-shots.

Implementation:
  - Reuses internal/util/fuzzy (sahilm/fuzzy), same scoring as the TUI
  - Default index: title + #tags + notes
  - --title-only restricts to titles
  - Filter: undone by default, --done | --all
  - --limit N caps results
  - --format plain/table/json (table reuses #6 renderer)
  - --json shortcut preserved, mutually exclusive with --format
  - Empty result: "no matches for <q>" in text, "[]" in JSON

Examples:
  tsk search milk
  tsk search "fix login" --limit 5
  tsk search dev --all
  tsk search docs --json | jq

Tests: 10 cases — title match, tag match, --title-only, done filter,
--all, --limit, --json non-empty, --json empty array, empty query
rejection, table format. All green with -race.

* fix(search): use pf helper to satisfy errcheck lint
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