diff --git a/crates/cli/src/commands.rs b/crates/cli/src/commands.rs index ae89a7d..c8f7429 100644 --- a/crates/cli/src/commands.rs +++ b/crates/cli/src/commands.rs @@ -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), diff --git a/crates/marqdo-host/src/host.rs b/crates/marqdo-host/src/host.rs index 5f6cfa0..cefe6e9 100644 --- a/crates/marqdo-host/src/host.rs +++ b/crates/marqdo-host/src/host.rs @@ -254,6 +254,13 @@ impl StdHost { args: Vec, ctx: &ExecutionContext, ) -> Result { + if !self.capabilities.console { + return Err(RuntimeError::new( + ErrorCategory::PermissionDenied, + ctx.span, + "program output (console) capability was not granted", + )); + } if args.len() != 1 { return Err(arity(ctx.span, "打印", 1, args.len())); }