fix(host,cli): enforce console capability and label call --json output

- host: `打印` checks the console capability at the execution point (pure and
  project modes grant it, but the boundary is now real instead of decorative).
- cli: `marqdo call --json` reports "command":"call" instead of "run".
This commit is contained in:
cflmy committed 2026-11-20 10:56:26 +08:00
1 parent 2f1b10d0ee
commit fae0cd4b18
2 files changed
+11 -3

No files matched your search

+4 -3
View File
@@ -485,6 +485,7 @@ pub fn execute(
json: bool,
trace: bool,
) -> i32 {
let command_name = if function.is_some() { "call" } else { "run" };
let project = match load_project(file, json) {
Ok(project) => project,
Err(code) => return code,
@@ -492,7 +493,7 @@ pub fn execute(
if project.has_errors() {
if json {
output::print_json(&json!({
"command": "run",
"command": command_name,
"success": false,
"diagnostics": output::diagnostics_json(&project.diagnostics),
}));
@@ -589,7 +590,7 @@ pub fn execute(
Ok(outcome) => {
if json {
output::print_json(&json!({
"command": "run",
"command": command_name,
"success": true,
"value": marqdo_value::to_wire(&outcome.value),
"stdout": stdout_text,
@@ -616,7 +617,7 @@ pub fn execute(
Err(error) => {
if json {
output::print_json(&json!({
"command": "run",
"command": command_name,
"success": false,
"stdout": stdout_text,
"error": runtime_error_json(&error, &project),