Skip to content

CLI gen: tri-state nullable bool option parser (--flag / --flag false / absent) #347

Description

@HavenDV

Part of #338. Depends on gap #1 (per-parameter flags).

Today

System.CommandLine's default Option<bool> is binary: presence means true, absence means false. There's no way to express "explicitly false" — which matters whenever a generated flag corresponds to a nullable: true boolean in the schema:

  • null (absent) → don't override the loaded base body
  • true → set field true
  • false → set field false

Without tri-state, --only-main-content (which means "yes") can't be distinguished from "omit" vs. "explicitly disable".

Target

firecrawl scrape <url> --only-main-content              # → true
firecrawl scrape <url> --only-main-content false        # → false
firecrawl scrape <url>                                  # → null (don't override)
firecrawl scrape <url> --input base.json --only-main-content false   # → override base to false

Proposed approach

  1. Emit Option<bool?> with custom parser for properties typed bool? (or bool with nullable: true):
    • parser accepts: nothing after the flag → true; true/yes/1true; false/no/0false; anything else → parse error.
  2. Helper factory in CliRuntime: CreateNullableBoolOption(string name, string? description) to keep the per-property emission concise.
  3. Help text: "true/false; presence alone implies true; omit to inherit".
  4. Plain bool properties (non-nullable, default false) stay as Option<bool> — no behavior change.

Acceptance criteria

  • Generated commands for nullable-bool body fields support all three states above.
  • Snapshot test covers a spec with a nullable boolean property.
  • Firecrawl scrape --only-main-content false works end-to-end after regen.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions