docs(maglevc): document -json; verified live against maglevd

Add the -json flag to maglevc(1): the contract verified by a live smoke
test against a maglevd (chbtl2) — show/query commands print the object
as JSON, actions (set/sync/config reload) print {} on success, and
failures print {"error": "..."} on stderr with a non-zero exit. JSON
output is never colorized. Also corrects the -color description (the
palette is now bright blue, shared from golang-cli) and refreshes the
man date.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-05 23:43:17 +02:00
parent d9a8ca6fb8
commit 12f17c0075
+29 -2
View File
@@ -1,10 +1,11 @@
.TH MAGLEVC 1 "April 2026" "vpp\-maglev" "User Commands"
.TH MAGLEVC 1 "June 2026" "vpp\-maglev" "User Commands"
.SH NAME
maglevc \- Maglev health\-checker CLI client
.SH SYNOPSIS
.B maglevc
[\fB\-server\fR \fIaddr\fR]
[\fB\-color\fR[=\fIbool\fR]]
[\fB\-json\fR]
[\fIcommand\fR [\fIargs\fR...]]
.SH DESCRIPTION
.B maglevc
@@ -38,7 +39,7 @@ gRPC server.
.RI "(default: " localhost:9090 "; env: " MAGLEV_SERVER )
.TP
.BR \-color [=\fIbool\fR]
Colorize static field labels in output using ANSI dark blue. The
Colorize static field labels in output using ANSI blue. The
default is mode\-aware: enabled (true) in the interactive shell, and
disabled (false) in one\-shot mode so that output piped into scripts
or files stays free of escape codes. Pass
@@ -47,6 +48,18 @@ or
.B \-color=false
explicitly to override the default for either mode.
.TP
.B \-json
Emit JSON instead of human\-readable text, for scripting. Every
.B show
or query command prints the underlying object as JSON; an action that
changes state
.RB ( set ", " sync ", " "config reload" )
prints
.B {}
on success; and any failure prints
.B {\(dqerror\(dq: \(dq...\(dq}
on stderr with a non\-zero exit status. JSON output is never colorized.
.TP
.B \-version
Print version, commit hash, and build date, then exit.
.SH EXAMPLES
@@ -84,6 +97,20 @@ Query VPP version and connection status, forcing color on:
$ maglevc \-color=true show vpp info
.EE
.RE
.PP
Emit JSON for scripting. A query returns the object; an action returns
.BR {} ;
a failure returns
.B {"error": ...}
with a non\-zero exit status:
.PP
.RS
.EX
$ maglevc \-json show frontend nginx\-ip4\-http
$ maglevc \-json sync vpp lb state
{}
.EE
.RE
.SH "FULL DOCUMENTATION"
This manpage documents only the invocation of
.BR maglevc .