jsdelivr / globalping-cli

A simple CLI tool to run networking commands remotely from hundreds of globally distributed servers
Mozilla Public License 2.0
129 stars 14 forks source link

Improve output handling #56

Closed MartinKolarik closed 1 year ago

MartinKolarik commented 1 year ago

Related to #55. We currently print the API response itself and some additional information. The extra information should always go to stderr. For example:

$ globalping http https://cdn.jsdelivr.net/npm --method GET
> NA, US, (FL), Tampa, ASN:29802, HIVELOCITY, Inc.
Invalid URL. The URL structure is /npm/package@version/file.js

The first line should go to stderr and the second to stdout. This makes it easier to programmatically process just one part of the output and matches how other CLIs work. If someone wants both parts, they can still merge it via 2>&1.

jimaek commented 1 year ago

The output itself doesn't change in this case right?

MartinKolarik commented 1 year ago

No, but running globalping http https://cdn.jsdelivr.net/npm --method GET > file means you only get the second line in the file and the first stays in the terminal.

MartinKolarik commented 1 year ago

Note that this makes processing the output easier for the most common --limit 1 scenario, but it's still tricky as soon as there are multiple responses. Some research would be useful to see how other tools handle this problem. Current ideas:

didil commented 1 year ago

I believe PR #58 fixes this as the results separator > NA, US ... now goes to stderr