Joseph Doherty 7cbe2756d0 mxaccesscli: clean up diag output
Rewrites DiagCommand to match the structure of read/write/subscribe:

- Output goes through CliFx's IConsole instead of System.Console
  (kills the 6 CliFx_SystemConsoleShouldBeAvoided build warnings).
- Single concise summary line at the top: `diag <tag>  (<sec>s, <status>)`.
- Status now correctly distinguishes ok / error / no-events. A bogus
  reference produces a DataChange event with MxCategoryConfigurationError;
  that reports as "error", not the previous (incorrect) "ok".
- Adds --llm-json mode mirroring read/write: { query, ok, results: [...] }
  with register/add_item/events/totals fields.
- Captures both DataChange and OperationComplete events with status
  detail rendered consistently.
- Drops the duplicate "Done. Total events: N" / "diag result: events=N"
  trailing lines.

Also fixes exit-code propagation from soft-failure commands. Environment
.ExitCode set inside ExecuteAsync was being overwritten by CliFx's own
return from RunAsync. Program.Main now folds the two:

    return cliFxExit != 0 ? cliFxExit : Environment.ExitCode

This restores correct exit-on-failure behavior for both `diag` (error
status) and `write` (timeout / non-Ok ack) without resorting to
CommandException, which would print "ERROR\n<stack trace>" even for an
empty message.

Verified:
  diag TestChildObject.TestInt   -> EXIT 0, "ok"
  diag NoSuchObject.NoSuchAttr   -> EXIT 1, "error"
  diag --llm-json                -> structured envelope, ok flag honors statuses

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-03 20:19:40 -04:00
S
Description
No description provided
3.4 MiB
Languages
C# 93.3%
TSQL 4.2%
PowerShell 1.5%
Shell 0.7%
Python 0.3%