Repository navigation
feat: add --format flag with table and csv output - #77
dogancanbakir wants to merge 4 commits into
Conversation
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.
|
@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 |
|
Warning Review limit reachedYou'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. View limit details
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. |
|
@dogancanbakir ci fails, would you check it again |
Same security bump as the dedicated fix PR; identical changes merge cleanly in any order.
b5f4899 to
949eb07
Compare
Closes #5
What
Adds a
--formatflag todit runto control output:dit run https://example.com --format table dit run https://example.com --format csv dit run https://example.com --format json # default, unchangedTable 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: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|csvcombined with--probais 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 fordit.PageResult/[]dit.FormResult, table rendering viatext/tabwriter, CSV rendering viaencoding/csv, andoutputPageResult/outputFormResultsdispatchers (JSON path byte-identical to the previous inline output).internal/cli/run.go: new--formatflag (defaultjson), 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 ./...andgo vet ./...pass.go test ./...: all packages pass, including the six newinternal/cliunit 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 onmainthere).--format xmland--format table --probaproduce the expected errors.