cli: add JSON output to get and list commands, and JSON and raw output to message poll

Open
#4,445 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 2 days

@shAn-kor is already working on this.

Since Oct 24, 2026.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
49/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Active
Tech stack
cli, rust
Domain
cli

Research direction

Start with core/cli/src/commands/binary_system/stats.rs for existing output options, core/cli/src/commands/binary_message/poll_messages.rs for poll formatting, and core/cli/src/main.rs for the execution line. Then locate get/list command definitions and tests; the issue does not enumerate them. Done when all get/list commands support the requested JSON output and message poll meets the output, encoding, stdout, and acceptance requirements.

Written by the indexing model from the issue text.

Description

enhancement tui

Problem

  • Only iggy stats can print JSON or TOML (-o json|toml, core/cli/src/commands/binary_system/stats.rs:243-244). All other get and list commands print tables, and the list commands use another flag, -l, --list-mode table|list. #749 asked for JSON output in 2024 and was closed after stats only (#756).
  • iggy message poll prints a table and converts each payload with String::from_utf8_lossy (core/cli/src/commands/binary_message/poll_messages.rs:141). Invalid UTF-8 prints as U+FFFD, and a payload with \n spans two rows. --output-file writes whole messages, but no option prints the payloads alone.
  • The Executing ... line goes to stdout (core/cli/src/main.rs:428-432), so iggy stats -o json | jq . fails. -q hides this line, but it also hides the output of all commands except stats and pat create. #772 asked to move the logs to stderr.

Proposal

  • Add -o, --output <table|list|json> to every get and list command, and keep -l, --list-mode for the list commands. Use the JSON shapes of the HTTP API, because the server response types already implement Serialize.
  • In the context commands, mask passwords and tokens, as context show does.
  • Add --output <table|json|raw> to message poll, with no short form, because -o is --offset there.
    • json writes one JSON object per message per line. Write the message ID as a string, because JavaScript and many JSON tools round 128-bit numbers.
    • --payload-encoding <base64|hex|utf8> sets the payload format, and the default is base64. utf8 fails on a payload that is not valid UTF-8.
    • raw writes only the payload bytes, each followed by \n.
  • In JSON and raw mode, write only the output to stdout.

Notes

  • TOML cannot hold a top-level array, so the list commands cannot print TOML.

Acceptance

  • jq can parse the output of every get and list command with -o json, and of message poll --output json.
  • For non-empty, single-line UTF-8 payloads, message poll --output raw | message send sends the same payloads again.
Dominant language
Rust
Stars
5.3k
Forks
548
Avg merge
2d 20h
Merged PRs (30d)
194

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from apache/iggy

All issues in apache/iggy

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.