mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-24 00:23:12 +09:00
Add --output json to clusterioctl
Commands print their results through a CommandOutput on the ctl link.
In json mode lists print as arrays of objects, other results as an
object, commands without a result print {} and failures print
{ error: ClassName, message } with exit code 1. log follow and
debug dump-ws print JSON lines.
Human output now goes through the shared asTable printer in every
command, results that were logged to stderr (role create, save and mod
upload/download) print to stdout, and config edit failures are logged
instead of printed.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
35f9609865
commit
10beffe167
23 files changed
+642
-269
No files matched your search
@@ -1,15 +1,13 @@
|
||||
|
||||
import * as lib from "@clusterio/lib";
|
||||
import { logger } from "@clusterio/lib";
|
||||
import type { Ctl } from "../ctl.js";
|
||||
import { asTable, print } from "./command_ops.js";
|
||||
import { print } from "./command_ops.js";
|
||||
|
||||
export const roleCommands = new lib.CommandTree({ name: "role", description: "Role management" });
|
||||
roleCommands.add(new lib.Command({
|
||||
definition: [["list", "l"], "List roles in the cluster"],
|
||||
handler: async function(args: object, ctl: Ctl) {
|
||||
let roles = await ctl.send(new lib.RoleListRequest());
|
||||
print(asTable(roles));
|
||||
ctl.output.table(await ctl.send(new lib.RoleListRequest()));
|
||||
},
|
||||
}));
|
||||
|
||||
@@ -27,7 +25,7 @@ roleCommands.add(new lib.Command({
|
||||
args.description,
|
||||
args.permissions,
|
||||
));
|
||||
logger.info(`Created role ID ${id}`);
|
||||
ctl.output.result({ id }, () => print(`Created role ID ${id}`));
|
||||
},
|
||||
}));
|
||||
|
||||
|
||||
Reference in new issue
Block a user