mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-27 01:41:40 +00:00
refactor(cli): separate json payload output from logging
This commit is contained in:
@@ -138,7 +138,7 @@ type PrintResultOptions = UpdateCommandOptions & {
|
||||
|
||||
export function printResult(result: UpdateRunResult, opts: PrintResultOptions): void {
|
||||
if (opts.json) {
|
||||
defaultRuntime.log(JSON.stringify(result, null, 2));
|
||||
defaultRuntime.writeJson(result);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -70,22 +70,16 @@ export async function updateStatusCommand(opts: UpdateStatusOptions): Promise<vo
|
||||
const updateLine = formatUpdateOneLiner(update).replace(/^Update:\s*/i, "");
|
||||
|
||||
if (opts.json) {
|
||||
defaultRuntime.log(
|
||||
JSON.stringify(
|
||||
{
|
||||
update,
|
||||
channel: {
|
||||
value: channelInfo.channel,
|
||||
source: channelInfo.source,
|
||||
label: channelLabel,
|
||||
config: configChannel,
|
||||
},
|
||||
availability: updateAvailability,
|
||||
},
|
||||
null,
|
||||
2,
|
||||
),
|
||||
);
|
||||
defaultRuntime.writeJson({
|
||||
update,
|
||||
channel: {
|
||||
value: channelInfo.channel,
|
||||
source: channelInfo.source,
|
||||
label: channelLabel,
|
||||
config: configChannel,
|
||||
},
|
||||
availability: updateAvailability,
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -178,7 +178,7 @@ type UpdateDryRunPreview = {
|
||||
|
||||
function printDryRunPreview(preview: UpdateDryRunPreview, jsonMode: boolean): void {
|
||||
if (jsonMode) {
|
||||
defaultRuntime.log(JSON.stringify(preview, null, 2));
|
||||
defaultRuntime.writeJson(preview);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user