mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-21 08:03:13 +09:00
Address second review of ctl --output
CommandOutput.error takes a human reporter like result, so command errors log their message in human mode and print JSON in json and wire mode. table takes a map applied to each row in human mode, which note list, host plugin list, user list and save list now use. Rename streaming to streamingLog, and print startup errors with errorToJson directly. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
8550df69eb
commit
23187859d6
11 files changed
+55
-36
No files matched your search
@@ -15,7 +15,7 @@ The easiest way to do this is to run `npx clusteriocontroller bootstrap create-c
|
||||
Print the result of the command as JSON on stdout instead of text meant for reading.
|
||||
Lists are printed as an array of objects, other results as an object, and commands that have no result print `{"success": true}`.
|
||||
If the command fails it prints `{"error": "<ClassName>", "message": "<message>"}` and exits with a non-zero exit code.
|
||||
Log messages, including the error message, are written to stderr in all formats.
|
||||
Log messages are written to stderr in all formats.
|
||||
|
||||
`--output wire` prints the same results in the format they are sent between the controller, hosts and clusterioctl, which uses snake_case names like `is_admin`.
|
||||
The `json` format uses the property names shown in the tables of the human format.
|
||||
|
||||
@@ -982,7 +982,7 @@ handler: async function(args, ctl) {
|
||||
```
|
||||
|
||||
`ctl.output.result(data, human)` prints `data` as JSON in json and wire mode and calls `human` otherwise.
|
||||
`ctl.output.table(rows)` prints an array of objects as a table or as a JSON array.
|
||||
`ctl.output.table(rows, map)` prints an array of objects as a JSON array, or as a table in human mode with `map` applied to each row first.
|
||||
`ctl.output.human` is true when the output is meant for reading.
|
||||
Commands that print nothing get `Command ran successfully` or `{"success": true}` printed for them, and errors thrown from the handler are printed as `{"error": "<ClassName>", "message": "<message>"}` in json and wire mode.
|
||||
|
||||
|
||||
Reference in new issue
Block a user