Skip to content

CLI: Add --json output flag across all read commands #86

Description

@PetarStoev02

Context

CLIs that produce machine-readable output are far more useful in scripts and CI pipelines. Adding a global --json flag lets users pipe w3-kit output into jq, other tools, or test harnesses without scraping text.

What to build

Implement a global --json flag that, when set, causes all read commands (e.g., chains list, chains show, future tokens list, etc.) to print structured JSON instead of human-formatted text. Write commands (scaffolding) are out of scope for this issue.

Acceptance criteria

  • --json flag works on every existing read command
  • JSON output is valid and stable (snapshot tests recommended)
  • Human and JSON output paths share the same data source
  • Errors when --json is set also produce JSON (e.g., { "error": "..." }) and exit with a non-zero code
  • Documented in --help

Pointers

  • Pairs well with the future chains and tokens commands
  • Reference: GitHub CLI (gh) uses --json field selection — start with simple full-payload JSON, field selection can be a follow-up

Complexity

🟡 Intermediate

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthelp wantedExtra attention is neededstaleInactive

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions