Commit Graph
8 Commits
Author SHA1 Message Date
Nick Vigilante d469763bc0 feat: add JSON output to coder ping (#30148)
`coder ping` printed per-pong lines and a summary table with no
structured output, so monitoring scripts had to parse text.

It now accepts `-o table|json` (default `table`, today's output) through
the shared CLI output formatter.
JSON is a single document at the end with each attempt (sequence, time,
latency, direct or DERP region, error) and the summary.

**Behavior change:** Additive.
Default output is unchanged.
`-o json` requires `--num` and fails early without it, because pings
otherwise continue until interrupted.
In JSON mode, the per-pong and diagnostic lines that normally go to
stdout go to stderr, so stdout contains only the JSON document.

<details>
<summary>Decisions</summary>

- One document at the end rather than streaming, because it's simpler to
parse.
- Require `--num` with `-o json`. In the default continuous mode, a
single document would leave stdout empty until Ctrl+C and hold every
pong in memory. Newline-delimited JSON per pong is a possible follow-up
if continuous machine-readable output is needed.
- Durations are reported as `*_ms` floats because `time.Duration`
doesn't marshal to a portable unit.
- Output goes through the shared `cliui.NewOutputFormatter` (table and
JSON), matching `coder speedtest`. This also adds the standard `-c,
--column` flag for the summary table.

</details>

<details>
<summary>CI note</summary>

`Storybook` failed once on 61b39ef70b inside Pixel (`build finished with
status failed`). This PR changes no frontend files; the job passed on
rerun.

`test-go-pg (ubuntu-latest)` failed on 8e6276921e in [run
38948569950](https://github.com/coder/coder/actions/runs/38948569950/job/117134059011)
on `TestChatTurnStopsAtStepLimit/Default` in `coderd/x/chatd`. This PR
doesn't touch `coderd/x/chatd`, so the failed job was re-run.

</details>

Closes [CLI-32](https://linear.app/codercom/issue/CLI-32)

_This PR was generated by Coder Agents on behalf of @nickvigilante._
2026-10-26 13:17:51 -04:00
Danny Kopping 4c438bd4d3 feat(cli): add local and UTC time options to ping cmd (#16648)
It's sometimes useful to see when each pong was received, for
correlating these times with other events.

---------

Signed-off-by: Danny Kopping <danny@coder.com>
2025-02-24 05:38:17 +00:00
Ethan b7c574f679 feat!: add summary to coder ping (#14762) 2024-09-25 13:24:23 +10:00
Ammar Bandukwala b63dfe7b75 perf(cli): optimize CPU consumption of help pages (#9607)
This change reduces the CPU consumption of --help by ~50%.

Also, this change removes ANSI escape codes from our golden files. I
don't think those were worth the inability to parallelize golden file tests and
global state fragility.
2023-09-14 19:48:29 -05:00
Ammar Bandukwala f703a5b34e chore(cli): lighten flags on help page (#9606) 2023-09-08 13:43:56 -05:00
Ammar Bandukwala e361f1107b feat(cli): colorize help page (#9589) 2023-09-08 18:21:33 +00:00
Ammar Bandukwala 2bd6d2908e feat: convert entire CLI to clibase (#6491)
I'm sorry.
2023-03-23 17:42:20 -05:00
Colin Adler a54de6093b feat: add coder ping (#6161) 2023-02-13 10:38:00 -06:00