torrust-tracker icon indicating copy to clipboard operation
torrust-tracker copied to clipboard

HTTP Tracker client: Add option to show response in pretty JSON

Open josecelano opened this issue 6 months ago • 0 comments

Parent issue: https://github.com/torrust/torrust-tracker/issues/669 Relates to: https://github.com/torrust/torrust-tracker/issues/1563

I usually pipe the client output through the console command "jq" to format the JSON response into a more readable format. It would be nice to add an option to do it without requiring an external command:

cargo run -p torrust-tracker-client --bin http_tracker_client announce https://tracker.torrust-demo.com 000620bbc6c52d5a96d98f6c0f1dfa523a40df82 | jq
{
  "complete": 2,
  "incomplete": 0,
  "interval": 300,
  "min interval": 300,
  "peers": [
    {
      "ip": "185.53.146.66",
      "peer id": [
        45,
        113,
        66,
        52,
        51,
        57,
        48,
        45,
        108,
        120,
        99,
        74,
        46,
        97,
        50,
        72,
        79,
        106,
        85,
        86
      ],
      "port": 45809
    }
  ]
}

The new command option could be format:

cargo run -p torrust-tracker-client --bin http_tracker_client announce https://tracker.torrust-demo.com 000620bbc6c52d5a96d98f6c0f1dfa523a40df82 --format pretty

josecelano avatar Jun 09 '25 10:06 josecelano