Skip to content

CLI gen: --input/--output/--output-dir convenience options on every command #343

@HavenDV

Description

@HavenDV

Part of #338. Complements gap #1 (per-parameter flags) and #4 (human formatters).

Today

Generated CLI emits only --request-file (path to a JSON file). No stdin support, no inline JSON, no output-to-file, no multi-file sink for paginated responses.

Firecrawl's Commands/ ships --input file.json|-, --output path.txt, --output-dir dir/ on every high-level command. Implemented entirely in CliRuntime once; reused across commands.

Target

# Read body from file, override one field
firecrawl scrape https://example.com --input ./scrape-config.json --only-main-content

# Read body from stdin
echo '{"formats":["markdown"]}' | firecrawl scrape https://example.com --input -

# Write formatted output to file
firecrawl scrape https://example.com --output result.txt

# Multi-page crawl, one file per page
firecrawl crawl https://example.com --wait --output-dir ./crawl-out/

Proposed approach

  1. --input option (replaces --request-file semantically): accepts a path, - for stdin, or an inline JSON string starting with { or [. The loaded body is merged with per-field flags (gap build(deps): Bump the all group with 1 update #1) — flags override loaded fields.
  2. --output option: when set, writes the rendered output (formatted or JSON depending on --json) to the given path instead of stdout.
  3. --output-dir option: emitted only on commands whose success response is paginated, an array, or has known multi-resource shape (crawl results, batch results, deep-research artifacts). Writes one file per item with a stable naming scheme:
    • if the item has url<sanitized-url>.md / .html / .metadata.json
    • else → 001.json, 002.json, ...
  4. Add helpers to CliRuntime: ReadInputAsync(string spec) -> string, WriteOutputAsync(string? path, string content), WritePageResultFilesAsync(string dir, IEnumerable<T> items).
  5. Backward compatibility: keep --request-file and --request-json as hidden aliases for --input (deprecation warning) so the rename doesn't break scripts.

Acceptance criteria

  • All four invocations above work on regenerated Firecrawl.Cli.
  • --input - reads stdin correctly when piped.
  • --output-dir produces one file per page for crawl results.
  • --request-json / --request-file still work with a deprecation warning.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions