forked from 1b-agent/opencadstudio-upstream
feat: SCRIPTCOMMANDS setting to turn script-driven commands off
A saved user preference (on by default) toggled by the SCRIPTCOMMANDS command gates HostApi::run_command; Cancel stays allowed so a waiting command is never stranded. The runner refuses the SCRIPTCOMMANDS command itself, so a script cannot change it. Documents why no helper-thread or stack-growing dependency was added: native builds link with at least 8 MiB, the nesting depth is fixed, and the deepest step found needs 2 to 4 MiB in a debug build. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
a25ae4f8c0
commit
2ed41586de
8 files changed
+120
-15
No files matched your search
@@ -2894,6 +2894,25 @@ impl OpenCADStudio {
|
||||
_ => self.command_line.push_error(crate::t!("Requires 0 or 1").as_ref()),
|
||||
}
|
||||
}
|
||||
cmd if cmd == "SCRIPTCOMMANDS" || cmd.starts_with("SCRIPTCOMMANDS ") => {
|
||||
// A user setting, deliberately outside the script's reach: it is refused by
|
||||
// the script command runner, so only the command line can change it.
|
||||
let arg = cmd.trim_start_matches("SCRIPTCOMMANDS").trim();
|
||||
match arg {
|
||||
"" => {}
|
||||
"1" | "ON" | "YES" => self.script_commands = true,
|
||||
"0" | "OFF" | "NO" => self.script_commands = false,
|
||||
_ => {
|
||||
self.command_line.push_error("SCRIPTCOMMANDS takes 1 (scripts may run commands) or 0 (they may not)");
|
||||
return Some(Task::none());
|
||||
}
|
||||
}
|
||||
if !arg.is_empty() {
|
||||
self.persist_settings_if_changed();
|
||||
}
|
||||
let state = if self.script_commands { 1 } else { 0 };
|
||||
self.command_line.push_output(&format!("SCRIPTCOMMANDS = {state}"));
|
||||
}
|
||||
"SAVETIME" => {
|
||||
use crate::command::ValuePromptCommand;
|
||||
let c = ValuePromptCommand::new(
|
||||
|
||||
Reference in new issue
Block a user