Skip to content

[good first issue] Add --pretty flag for indented JSON output (distinct from --human) #3

@abhicris

Description

@abhicris

Context

Every subcommand in src/commands.rs calls output::emit(mode, label, value) with the result, and src/output.rs chooses between Mode::Json and Mode::Human. But the global --human flag only enables pretty-printing — it does not pretty-print JSON itself. Agents consuming JSON from stdout and humans debugging in a terminal both benefit from the jq-style indented variant.

Scope

  • In src/output.rs:
    • Add Mode::JsonPretty variant.
    • Update emit:
      • Mode::Jsonserde_json::to_string(value) (compact — existing behavior).
      • Mode::JsonPrettyserde_json::to_string_pretty(value).
      • Mode::Human → existing pretty colored output.
  • In src/main.rs:
    • Add --pretty global flag. Mutually exclusive with --human.
    • If --pretty is set, use Mode::JsonPretty.
  • Update README's example outputs to include --pretty examples.

Acceptance criteria

  • arbitrum-cli block latest → single-line JSON (unchanged).
  • arbitrum-cli block latest --pretty → indented JSON.
  • arbitrum-cli block latest --human → colored table (unchanged).
  • --human --pretty exits non-zero with a clear clap error.
  • All existing tests pass.

Reference: src/output.rs::emit is 30 lines; PR #2 (feat: agent-deposit command + GitHub Actions CI) for CI/test expectations.

Estimated effort

S (1–2 hours)

kcolbchain / Abhishek Krishna

Metadata

Metadata

Assignees

No one assigned

    Labels

    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