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
@@ -64,16 +64,25 @@ describe("ctl/command_ops", function() {
|
||||
it("prints success for commands without a result", function() {
|
||||
assert.deepEqual(captureLog(() => new CommandOutput("json").finish()), ['{"success":true}']);
|
||||
const streaming = new CommandOutput("json");
|
||||
streaming.streaming = true;
|
||||
streaming.streamingLog = true;
|
||||
assert.deepEqual(captureLog(() => streaming.finish()), []);
|
||||
});
|
||||
it("prints errors as JSON", function() {
|
||||
const output = new CommandOutput("json");
|
||||
const lines = captureLog(() => {
|
||||
output.error(new lib.CommandError("failed"));
|
||||
output.error(new lib.CommandError("failed"), () => assert.fail("called human formatter"));
|
||||
output.finish();
|
||||
});
|
||||
assert.deepEqual(lines, ['{"error":"CommandError","message":"failed"}']);
|
||||
});
|
||||
it("calls the human error reporter in human mode", function() {
|
||||
const output = new CommandOutput("human");
|
||||
const human = () => console.log("failed"); // eslint-disable-line no-console
|
||||
const lines = captureLog(() => {
|
||||
output.error(new lib.CommandError("failed"), human);
|
||||
output.finish();
|
||||
});
|
||||
assert.deepEqual(lines, ["failed"]);
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user