feat(tracker-client): add HTTP response format option#1758
Merged
josecelano merged 2 commits intoMay 11, 2026
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a --format output option to the HTTP tracker client so users can choose between compact (single-line) and pretty (indented) JSON output for announce and scrape, addressing the “pretty JSON” request in issue #1562.
Changes:
- Introduces an
OutputFormatclapValueEnum(compactdefault,pretty) forannounceandscrape. - Adds a format-aware
serialize_jsonhelper and applies it to typed responses and the JSON fallback path. - Updates module-level examples and adds unit tests for compact vs pretty serialization.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #1758 +/- ##
===========================================
- Coverage 79.41% 79.40% -0.01%
===========================================
Files 368 368
Lines 27160 27182 +22
Branches 27160 27182 +22
===========================================
+ Hits 21568 21584 +16
- Misses 5309 5314 +5
- Partials 283 284 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Member
Author
|
ACK 2bfeabd |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements issue #1562 by adding output format selection to the HTTP tracker client.
Changes included
--formatoption to HTTPannounceandscrapecommands.compact(default)prettyManual verification
Verified locally against
http://127.0.0.1:7070:announce --format compactoutputs single-line JSON.announce --format prettyoutputs indented multiline JSON.scrape(without--format) outputs compact single-line JSON.--formatvalue is rejected by clap with allowed values.Verification
cargo test -p torrust-tracker-client console::clients::http::app::testscargo check -p torrust-tracker-clientlinter allcargo macheteIssue