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:
parent
208e617868
commit
f0f9a57bf6
3 changed files with 36 additions and 13 deletions
|
|
@ -914,7 +914,13 @@ impl OpenCADStudio {
|
||||||
|
|
||||||
// DATALINK <path.csv> — import a CSV file into a table placed at the
|
// 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).
|
// 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();
|
let path = cmd.trim_start_matches("DATALINK").trim();
|
||||||
if path.is_empty() {
|
if path.is_empty() {
|
||||||
self.command_line.push_info(
|
self.command_line.push_info(
|
||||||
|
|
@ -968,7 +974,14 @@ impl OpenCADStudio {
|
||||||
// LANDXMLIMPORT <path> — import survey points (LandXML <CgPoint>
|
// LANDXMLIMPORT <path> — import survey points (LandXML <CgPoint>
|
||||||
// elements) as Point objects. Reads the coordinate text content
|
// elements) as Point objects. Reads the coordinate text content
|
||||||
// (northing easting elevation) → Point at (easting, northing, elev).
|
// (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();
|
let path = cmd.trim_start_matches("LANDXMLIMPORT").trim();
|
||||||
if path.is_empty() {
|
if path.is_empty() {
|
||||||
self.command_line.push_info(
|
self.command_line.push_info(
|
||||||
|
|
|
||||||
|
|
@ -330,11 +330,13 @@ impl OpenCADStudio {
|
||||||
// SCRIPT <path> — run a command script: each non-blank, non-comment
|
// SCRIPT <path> — run a command script: each non-blank, non-comment
|
||||||
// line is fed through the same command path the `--script` startup
|
// line is fed through the same command path the `--script` startup
|
||||||
// flag uses, so the behaviour matches headless automation exactly.
|
// flag uses, so the behaviour matches headless automation exactly.
|
||||||
cmd if cmd == "SCRIPT"
|
"SCRIPT" | "SCR" => {
|
||||||
|| cmd == "SCR"
|
use crate::command::ValuePromptCommand;
|
||||||
|| cmd.starts_with("SCRIPT ")
|
let c = ValuePromptCommand::new("SCRIPT", "SCRIPT path to the .scr file:");
|
||||||
|| cmd.starts_with("SCR ") =>
|
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());
|
let path = cmd.split_once(' ').map(|(_, r)| r.trim().to_string());
|
||||||
match path {
|
match path {
|
||||||
Some(p) if !p.is_empty() => match std::fs::read_to_string(&p) {
|
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
|
// CUIEXPORT <path> — write the keyboard-shortcut customizations
|
||||||
// (the drawing-independent CUI data) to a plain "KEY COMMAND" file.
|
// (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();
|
let path = cmd.trim_start_matches("CUIEXPORT").trim();
|
||||||
if path.is_empty() {
|
if path.is_empty() {
|
||||||
self.command_line.push_info(
|
self.command_line.push_info(
|
||||||
|
|
@ -259,11 +265,13 @@ impl OpenCADStudio {
|
||||||
|
|
||||||
// CUIIMPORT / CUILOAD <path> — load shortcut customizations from a
|
// CUIIMPORT / CUILOAD <path> — load shortcut customizations from a
|
||||||
// "KEY COMMAND" file (lines starting with # are ignored).
|
// "KEY COMMAND" file (lines starting with # are ignored).
|
||||||
cmd if cmd == "CUIIMPORT"
|
"CUIIMPORT" | "CUILOAD" => {
|
||||||
|| cmd == "CUILOAD"
|
use crate::command::ValuePromptCommand;
|
||||||
|| cmd.starts_with("CUIIMPORT ")
|
let c = ValuePromptCommand::new("CUIIMPORT", "CUIIMPORT shortcuts file to load:");
|
||||||
|| cmd.starts_with("CUILOAD ") =>
|
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
|
let path = cmd
|
||||||
.trim_start_matches("CUIIMPORT")
|
.trim_start_matches("CUIIMPORT")
|
||||||
.trim_start_matches("CUILOAD")
|
.trim_start_matches("CUILOAD")
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue