CLI gen: default human-readable response formatter with --json toggle
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 92
- Forks
- 8
- Avg merge
- 1d 6h
- Merged PRs (30d)
- 4
Description
Part of #338.
Today
Every generated command calls CliRuntime.WriteJsonAsync(...) — raw JSON is the only output. Users who want a readable terminal view (let alone scrubbing structured data into a pipeline) have to write custom formatters per response type.
Firecrawl's Commands/ ships FormatScrapeResponse, FormatCrawlStatus, FormatStartResult, etc. — hundreds of lines of hand-written formatting. The pattern is uniform: walk the response, highlight key scalars, render arrays as bullets, render dates with a sensible format.
Target
Default to a generic schema-walking formatter; opt out to raw JSON with --json.
$ firecrawl scrape https://example.com
URL: https://example.com
Status: success
Markdown: # Example Domain ...
Metadata:
- title: Example Domain
- language: en
- statusCode: 200
$ firecrawl scrape https://example.com --json
{"url":"...","markdown":"...",...}
Proposed approach
- Generate a
Format<TResponse>(TResponse value)method per response type that walks the model'sPropertyData:- scalar →
key: valueline - string > 80 chars → truncate with ellipsis (full text behind
--jsonor--output file.txt) - array of scalar → multi-line bullets
- nested object → indented sub-section
- array of object → numbered entries with two-level indent
- dates →
yyyy-MM-dd HH:mm:ss UTC
- scalar →
--jsonrecursive option at the root command level (added to existing--api-key/--base-urlset) flips output mode. Already half-present:CliRuntime.WriteJsonAsyncexists; needs a siblingWriteFormattedAsync.- Vendor extension
x-cli-formaton a property:key→ render at the top of the outputhidden→ skip from formatted view (still in--json)code→ render in a code-block style (preformatted)
- Partial-class hook for full override:
partial class ScrapeCommand { static partial Task<string> CustomizeFormatAsync(Response response, ParseResult ctx); } - Mirror to
CliGenerator.cs.
Acceptance criteria
- Default
firecrawl scrape <url>shows human-readable output,--jsonshows raw JSON. x-cli-format: keyon a property promotes it to the top of the output.- Partial-class override works without touching the generated
.g.csfile. - Snapshot tests cover at least: simple scalar response, nested object, array of objects, mixed.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading Commands/, CliRuntime.WriteJsonAsync, and CliGenerator.cs to understand the existing generated-command output path. Use the requested snapshot coverage for scalar, nested-object, array-of-object, and mixed responses as the starting test map. Done means default formatted output, root-level --json raw output, x-cli-format handling, and partial-class overrides without editing generated .g.cs files.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- cli, tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100