Skip to content

feat: add --format flag with table and csv output - #77

Open
dogancanbakir wants to merge 4 commits into
mainfrom
claude/issue-5-output-formats
Open

dogancanbakir wants to merge 4 commits into
mainfrom
claude/issue-5-output-formats

Conversation

@dogancanbakir

@dogancanbakir dogancanbakir commented Nov 1, 2026 •

Copy link
Copy Markdown
Member

Closes #5

What

Adds a --format flag to dit run to control output:

dit run https://example.com --format table
dit run https://example.com --format csv
dit run https://example.com --format json   # default, unchanged

Table and CSV share one flat schema with one row per classified field, so results are easy to inspect at a glance and pipe into tools like awk, cut, or a spreadsheet:

PAGE_TYPE  CAPTCHA_TYPE  FORM  FORM_TYPE  FIELD     FIELD_TYPE
login      recaptcha     1     login      password  password
login      recaptcha     1     login      username  username or email
page_type,captcha_type,form,form_type,field,field_type
login,recaptcha,1,login,password,password
login,recaptcha,1,login,username,username or email

Forms with no fields and pages with no forms still emit a row, fields are sorted by name for deterministic output, and the forms-only fallback (no page model) uses the same schema with an empty page_type. An unknown format value errors out, and --format table|csv combined with --proba is rejected with a pointer to --format json (probability maps do not flatten usefully into rows).

Changes

  • internal/cli/format.go (new): format constants and validation, row flattening for dit.PageResult / []dit.FormResult, table rendering via text/tabwriter, CSV rendering via encoding/csv, and outputPageResult / outputFormResults dispatchers (JSON path byte-identical to the previous inline output).
  • internal/cli/run.go: new --format flag (default json), early validation, and the non-proba output sites routed through the dispatchers; help-text examples.
  • internal/cli/format_test.go (new): unit tests for format validation and exact table/CSV/JSON output, including no-forms and no-fields edge cases.
  • README.md: documented the format examples.

Testing

  • go build ./... and go vet ./... pass.
  • go test ./...: all packages pass, including the six new internal/cli unit tests; the only failures are the two pre-existing root-package functional tests that need to download the pretrained model from Hugging Face, which was blocked in my sandbox (they fail identically on main there).
  • Smoke-tested the built binary: --format xml and --format table --proba produce the expected errors.

Add a --format flag to the run command to control output:

    dit run https://example.com --format table
    dit run https://example.com --format csv

JSON remains the default and is unchanged. Table (aligned via
text/tabwriter) and CSV share one flat schema -- page_type,
captcha_type, form, form_type, field, field_type -- with one row per
classified field, so results are easy to inspect and pipe into other
tools. Fields are sorted by name for deterministic output. An unknown
format or combining table/csv with --proba returns an error.
errcheck flagged the unchecked fmt.Fprintln calls in format.go; the
toolchain bump clears the repo-wide GO-2026-6809 Govulncheck failure.

dogancanbakir commented Nov 1, 2026 •

Copy link
Copy Markdown
Member Author

@recepgunes1 fixed — the Govulncheck failure was repo-wide: CI installs the toolchain from go.mod, and go1.26.9 is affected by GO-2026-6809. This branch now carries the one-line go1.26.10 bump (standalone green; identical change in the sibling PRs and in the dedicated bump PR, merges cleanly in any order). The Lint failure (unchecked fmt.Fprintln returns in format.go) is also fixed.

@coderabbitai

coderabbitai Bot commented Nov 1, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 59 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: f25d5f28-98df-404d-9cd4-ec43a588d328
Commits

Reviewing files that changed from the base of the PR and between b41c174 and 949eb07.

Files ignored due to path filters: 1
  • go.sum is excluded by !**/*.sum
Files selected for processing: 5
  • README.md
  • go.mod
  • internal/cli/format.go
  • internal/cli/format_test.go
  • internal/cli/run.go
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@recepgunes1

Copy link
Copy Markdown
Member

@dogancanbakir ci fails, would you check it again

Same security bump as the dedicated fix PR; identical changes merge
cleanly in any order.
@dogancanbakir dogancanbakir changed the title PR title feat: add --format flag with table and csv output Nov 1, 2026
@dogancanbakir
dogancanbakir force-pushed the claude/issue-5-output-formats branch from b5f4899 to 949eb07 Compare November 2, 2026 05:23
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.

Multiple output formats (table, csv, json)

2 participants