mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-21 08:03:13 +09:00
Address review of ctl --output
Add a wire output format that prints the toJSON format sent over the link. Commands without a result print {"success": true}, or "Command ran successfully" in human mode. The missing URL check throws a StartupError, unexpected command errors are rethrown to the startup handler, and startup errors log as fatal. user list, note list and host plugin list print the objects they received instead of their table rows.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
10beffe167
commit
8550df69eb
13 files changed
+131
-112
No files matched your search
@@ -981,9 +981,10 @@ handler: async function(args, ctl) {
|
||||
},
|
||||
```
|
||||
|
||||
`ctl.output.result(data, human)` prints `data` as JSON in json mode and calls `human` otherwise.
|
||||
`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.
|
||||
Commands that print nothing get `{}` printed for them in json mode, and errors thrown from the handler are printed as `{"error": "<ClassName>", "message": "<message>"}`.
|
||||
`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.
|
||||
|
||||
To have the command tree become part of clusterioctl it needs to be added to the rootCommand tree in the `addCommands` hook of the ctl entrypoint:
|
||||
|
||||
|
||||
Reference in new issue
Block a user