forked from 1b-agent/opencadstudio-upstream
feat(commands): prompt the path/file commands for their path (bucket D)
SCRIPT/SCR, DATALINK, LANDXMLIMPORT, CUIEXPORT, CUIIMPORT/CUILOAD now prompt for the path via ValuePromptCommand instead of printing usage when run bare; each dispatches `NAME <path>` to the existing inline handler. The path keeps its case (dispatch does not upper-case arguments), so case-sensitive paths on Linux/macOS still resolve. A native file dialog would be a nicer follow-up.
This commit is contained in:
1 parent
208e617868
commit
f0f9a57bf6
3 files changed
+36
-13
No files matched your search
@@ -914,7 +914,13 @@ impl OpenCADStudio {
|
||||
|
||||
// DATALINK <path.csv> — import a CSV file into a table placed at the
|
||||
// origin (one-time import; a live re-reading link is future work).
|
||||
cmd if cmd == "DATALINK" || cmd.starts_with("DATALINK ") => {
|
||||
"DATALINK" => {
|
||||
use crate::command::ValuePromptCommand;
|
||||
let c = ValuePromptCommand::new("DATALINK", "DATALINK path to the .csv file:");
|
||||
self.command_line.push_info(&c.prompt());
|
||||
self.tabs[i].active_cmd = Some(Box::new(c));
|
||||
}
|
||||
cmd if cmd.starts_with("DATALINK ") => {
|
||||
let path = cmd.trim_start_matches("DATALINK").trim();
|
||||
if path.is_empty() {
|
||||
self.command_line.push_info(
|
||||
@@ -968,7 +974,14 @@ impl OpenCADStudio {
|
||||
// LANDXMLIMPORT <path> — import survey points (LandXML <CgPoint>
|
||||
// elements) as Point objects. Reads the coordinate text content
|
||||
// (northing easting elevation) → Point at (easting, northing, elev).
|
||||
cmd if cmd == "LANDXMLIMPORT" || cmd.starts_with("LANDXMLIMPORT ") => {
|
||||
"LANDXMLIMPORT" => {
|
||||
use crate::command::ValuePromptCommand;
|
||||
let c =
|
||||
ValuePromptCommand::new("LANDXMLIMPORT", "LANDXMLIMPORT path to the .xml file:");
|
||||
self.command_line.push_info(&c.prompt());
|
||||
self.tabs[i].active_cmd = Some(Box::new(c));
|
||||
}
|
||||
cmd if cmd.starts_with("LANDXMLIMPORT ") => {
|
||||
let path = cmd.trim_start_matches("LANDXMLIMPORT").trim();
|
||||
if path.is_empty() {
|
||||
self.command_line.push_info(
|
||||
|
||||
@@ -330,11 +330,13 @@ impl OpenCADStudio {
|
||||
// SCRIPT <path> — run a command script: each non-blank, non-comment
|
||||
// line is fed through the same command path the `--script` startup
|
||||
// flag uses, so the behaviour matches headless automation exactly.
|
||||
cmd if cmd == "SCRIPT"
|
||||
|| cmd == "SCR"
|
||||
|| cmd.starts_with("SCRIPT ")
|
||||
|| cmd.starts_with("SCR ") =>
|
||||
{
|
||||
"SCRIPT" | "SCR" => {
|
||||
use crate::command::ValuePromptCommand;
|
||||
let c = ValuePromptCommand::new("SCRIPT", "SCRIPT path to the .scr file:");
|
||||
self.command_line.push_info(&c.prompt());
|
||||
self.tabs[i].active_cmd = Some(Box::new(c));
|
||||
}
|
||||
cmd if cmd.starts_with("SCRIPT ") || cmd.starts_with("SCR ") => {
|
||||
let path = cmd.split_once(' ').map(|(_, r)| r.trim().to_string());
|
||||
match path {
|
||||
Some(p) if !p.is_empty() => match std::fs::read_to_string(&p) {
|
||||
|
||||
@@ -235,7 +235,13 @@ impl OpenCADStudio {
|
||||
|
||||
// CUIEXPORT <path> — write the keyboard-shortcut customizations
|
||||
// (the drawing-independent CUI data) to a plain "KEY COMMAND" file.
|
||||
cmd if cmd == "CUIEXPORT" || cmd.starts_with("CUIEXPORT ") => {
|
||||
"CUIEXPORT" => {
|
||||
use crate::command::ValuePromptCommand;
|
||||
let c = ValuePromptCommand::new("CUIEXPORT", "CUIEXPORT file to save shortcuts to:");
|
||||
self.command_line.push_info(&c.prompt());
|
||||
self.tabs[i].active_cmd = Some(Box::new(c));
|
||||
}
|
||||
cmd if cmd.starts_with("CUIEXPORT ") => {
|
||||
let path = cmd.trim_start_matches("CUIEXPORT").trim();
|
||||
if path.is_empty() {
|
||||
self.command_line.push_info(
|
||||
@@ -259,11 +265,13 @@ impl OpenCADStudio {
|
||||
|
||||
// CUIIMPORT / CUILOAD <path> — load shortcut customizations from a
|
||||
// "KEY COMMAND" file (lines starting with # are ignored).
|
||||
cmd if cmd == "CUIIMPORT"
|
||||
|| cmd == "CUILOAD"
|
||||
|| cmd.starts_with("CUIIMPORT ")
|
||||
|| cmd.starts_with("CUILOAD ") =>
|
||||
{
|
||||
"CUIIMPORT" | "CUILOAD" => {
|
||||
use crate::command::ValuePromptCommand;
|
||||
let c = ValuePromptCommand::new("CUIIMPORT", "CUIIMPORT shortcuts file to load:");
|
||||
self.command_line.push_info(&c.prompt());
|
||||
self.tabs[i].active_cmd = Some(Box::new(c));
|
||||
}
|
||||
cmd if cmd.starts_with("CUIIMPORT ") || cmd.starts_with("CUILOAD ") => {
|
||||
let path = cmd
|
||||
.trim_start_matches("CUIIMPORT")
|
||||
.trim_start_matches("CUILOAD")
|
||||
|
||||
Reference in new issue
Block a user