Skip to content

feat(cli): add --select flag for csv/json value column selection#140

Merged
fahimfaisaal merged 5 commits into
mainfrom
feat/cols-flag
Jun 20, 2026
Merged

feat(cli): add --select flag for csv/json value column selection#140
fahimfaisaal merged 5 commits into
mainfrom
feat/cols-flag

Conversation

@fahimfaisaal

@fahimfaisaal fahimfaisaal commented Jun 20, 2026

Copy link
Copy Markdown
Member

Summary

Adds a --select flag to the root command and all chart subcommands for selecting which CSV/JSON columns become chart value series, with optional rename via {label} syntax.

When omitted, behavior is unchanged — numeric columns are still auto-detected.

Usage

vizb sales.csv --select=price,count
vizb sales.csv --select=price{Unit price},count{Total count per week}
vizb sales.csv --select="price{USD}",count   # quote names containing , { or }

Behavior

Case Result
csv/json parser Only listed columns charted, in flag order
Benchmark parsers (go, rs:, js:) Warning to stderr, flag ignored
Column in both --select and --group Hard error
Non-numeric column in --select Hard error
Flag omitted Auto-detect unchanged

Implementation

  • pkg/parser/select_spec.go — quote-aware parsing, {rename}, group overlap validation
  • CommonOptions — flag wired through parser.Config.Select (parser/input layer, not chart-specific)
  • pkg/parser/csv and pkg/parser/json — explicit column resolution + renamed Stat.Type
  • Docs updated in tabular data guide and command reference

Also

  • Taskfile.yml — auto-run pnpm install in build:docs, build:ui, and format when node_modules is missing (fixes fresh worktree builds)

Test plan

  • go test ./... passes
  • task build passes (docs, UI, CLI binary)
  • Unit tests for flag parsing, CSV/JSON explicit selection, pipeline warning

@codecov-commenter

codecov-commenter commented Jun 20, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 79.66102% with 36 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
pkg/parser/select_spec.go 66.66% 16 Missing and 8 partials ⚠️
pkg/parser/json/json.go 79.06% 6 Missing and 3 partials ⚠️
cmd/cli/options.go 80.00% 2 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

Parse comma-separated column specs with optional {rename} labels and
quote escaping. Wire through CommonOptions into csv/json parsers with
flag-order series, group overlap validation, and a warning when used
with benchmark parsers.
Fresh worktrees were missing node_modules, causing astro/prettier not
found errors. Run pnpm install when node_modules is absent.
Use strconv.Unquote for quoted names, reuse chartColumns for numeric
checks, inline group overlap validation and display labels, drop
low-value tests.
Renames the csv/json value-column flag, config field, parser helpers,
tests, and docs for clearer intent.
@fahimfaisaal fahimfaisaal changed the title feat(cli): add --cols flag for csv/json value column selection feat(cli): add --select flag for csv/json value column selection Jun 20, 2026
Add unit tests for flag parsing failures, invalid ParseConfig input,
and JSON explicit column resolution errors to close patch coverage gaps.
@fahimfaisaal
fahimfaisaal merged commit 4222bca into main Jun 20, 2026
@fahimfaisaal
fahimfaisaal deleted the feat/cols-flag branch June 20, 2026 05:47
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.

2 participants