Execute command scripts through full input runner

This commit is contained in:
ramox81 committed 2026-09-08 13:52:18 +03:00
1 parent 8bb6703c70
commit d426012660
4 files changed
+20 -8

No files matched your search

+4 -6
View File
@@ -335,9 +335,9 @@ impl OpenCADStudio {
"PERSP" => return Some(Task::done(Message::SetProjection(false))),
"LAYERS" => return Some(Task::done(Message::ToggleLayers)),
// SCRIPT <path> — run a command script: each non-blank, non-comment
// SCRIPT <path> — run a command script: each non-comment
// line is fed through the same command path the `--script` startup
// flag uses, so the behaviour matches headless automation exactly.
// flag uses. Blank rows submit Enter to the active command.
"SCRIPT" | "SCR" => {
use crate::command::ValuePromptCommand;
let c = ValuePromptCommand::new("SCRIPT", "SCRIPT path to the .scr file:");
@@ -352,10 +352,8 @@ impl OpenCADStudio {
let cmds: Vec<Task<Message>> = text
.lines()
.map(str::trim)
.filter(|l| {
!l.is_empty() && !l.starts_with('#') && !l.starts_with(';')
})
.map(|l| Task::done(Message::Command(l.to_string())))
.filter(|l| !l.starts_with('#') && !l.starts_with(';'))
.map(|l| Task::done(Message::ScriptLine(l.to_string())))
.collect();
self.command_line.push_output(crate::tf!(
"SCRIPT: running {} command(s) from {p}.",
+5 -1
View File
@@ -2117,6 +2117,10 @@ pub enum Message {
CommandInput(String),
CommandSubmit,
Command(String),
/// Execute one complete line read from a command script. Unlike UI/ribbon
/// dispatch, this accepts an interactive verb and all of its arguments on
/// the same line (`BOX 0,0,0 10,10,0 10`).
ScriptLine(String),
/// Append one typed character to the command-line input from the
/// global key-press subscription. Used when the text-input widget
/// itself isn't focused (focus parked on viewport / button / etc.)
@@ -3832,7 +3836,7 @@ impl OpenCADStudio {
Task::batch(
cfg.script_lines
.into_iter()
.map(|line| Task::done(Message::Command(line))),
.map(|line| Task::done(Message::ScriptLine(line))),
)
};
s.queue_startup_prompts();
+8
View File
@@ -1953,6 +1953,14 @@ impl OpenCADStudio {
self.dispatch_command(&cmd)
}
Message::ScriptLine(line) => {
if line.trim().is_empty() {
self.feed_command(crate::command::StepInput::Enter)
} else {
self.run_command_line(&line)
}
}
Message::ToggleLayers => {
if self.active_modal == Some(super::ModalKind::Layers) {
self.ribbon.deactivate_tool_if("LAYERS");
+3 -1
View File
@@ -134,7 +134,9 @@ fn main() -> iced::Result {
Ok(text) => text
.lines()
.map(str::trim)
.filter(|l| !l.is_empty() && !l.starts_with('#'))
// Blank script rows are significant: they submit Enter to
// the active command (for example, accepting a preview).
.filter(|l| !l.starts_with('#') && !l.starts_with(';'))
.map(str::to_string)
.collect(),
Err(e) => {