Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions src/commands/config_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1965,14 +1965,24 @@ pub fn cmd_config(ctx: &RunContext, action: ConfigCmd) -> Result<()> {
ConfigCmd::Layout {
file,
page,
only_new,
save_as,
} => {
let data = fs::read(&file).with_context(|| format!("Cannot read {}", file))?;
let mut editor = ConfigEditor::load(&data)?;
let page_sel = page.as_deref().unwrap_or("Type:Page");

let count = editor.grid_layout(page_sel)?;
println!("✓ Laid out {} elements", count);
if only_new {
let count = editor.incremental_layout(page_sel)?;
if count == 0 {
println!("✓ No unpositioned blocks — nothing to place");
} else {
println!("✓ Placed {} new block(s), existing layout untouched", count);
}
} else {
let count = editor.grid_layout(page_sel)?;
println!("✓ Laid out {} elements", count);
}

save_edited(&editor, &file, save_as.as_deref())?;
}
Expand Down
16 changes: 8 additions & 8 deletions src/config_edit/describe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1107,7 +1107,7 @@ fn resolve_source_endpoint<'a>(
impl ConfigEditor {
fn room_names(&self) -> HashMap<String, String> {
let mut room_names = HashMap::new();
for e in self.iter_elements(&self.root) {
for e in Self::iter_elements(&self.root) {
if e.attributes.get("Type").map(|s| s.as_str()) == Some("Place")
&& let (Some(u), Some(t)) = (e.attributes.get("U"), e.attributes.get("Title"))
{
Expand All @@ -1126,7 +1126,7 @@ impl ConfigEditor {
std::collections::HashMap::new();
let mut cat_names: std::collections::HashMap<String, String> =
std::collections::HashMap::new();
for e in self.iter_elements(&self.root) {
for e in Self::iter_elements(&self.root) {
match e.attributes.get("Type").map(|s| s.as_str()) {
Some("Place") => {
if let (Some(u), Some(t)) = (e.attributes.get("U"), e.attributes.get("Title")) {
Expand Down Expand Up @@ -1196,7 +1196,7 @@ impl ConfigEditor {
"CommDMX",
];

for e in self.iter_elements(&self.root) {
for e in Self::iter_elements(&self.root) {
let etype = e.attributes.get("Type").cloned().unwrap_or_default();
if skip_types.contains(&etype.as_str()) || etype.is_empty() {
continue;
Expand Down Expand Up @@ -1307,7 +1307,7 @@ impl ConfigEditor {
pub fn describe_config_structured(&self, room_filter: Option<&str>) -> Vec<DescribeRoomEntry> {
// Build room UUID → name map
let mut room_names: HashMap<String, String> = HashMap::new();
for e in self.iter_elements(&self.root) {
for e in Self::iter_elements(&self.root) {
if e.attributes.get("Type").map(|s| s.as_str()) == Some("Place")
&& let (Some(u), Some(t)) = (e.attributes.get("U"), e.attributes.get("Title"))
{
Expand Down Expand Up @@ -1367,7 +1367,7 @@ impl ConfigEditor {

let mut by_room: HashMap<String, Vec<DescribeBlockEntry>> = HashMap::new();

for e in self.iter_elements(&self.root) {
for e in Self::iter_elements(&self.root) {
let etype = e.attributes.get("Type").cloned().unwrap_or_default();
if skip_types.contains(&etype.as_str()) || etype.is_empty() {
continue;
Expand Down Expand Up @@ -1453,7 +1453,7 @@ impl ConfigEditor {
let connector_map = Self::connector_map();
let mut endpoints_by_uuid: HashMap<String, Vec<ConnectorLookupEntry>> = HashMap::new();

for block in self.iter_elements(&self.root) {
for block in Self::iter_elements(&self.root) {
if block.name != "C" {
continue;
}
Expand Down Expand Up @@ -1502,7 +1502,7 @@ impl ConfigEditor {

let mut wires = Vec::new();

for block in self.iter_elements(&self.root) {
for block in Self::iter_elements(&self.root) {
if block.name != "C" {
continue;
}
Expand Down Expand Up @@ -1672,7 +1672,7 @@ impl ConfigEditor {
// Device bus: "Tree" | "Air" | "Network" → Vec<device_name>
let mut device_bus: HashMap<String, Vec<String>> = HashMap::new();

for elem in self.iter_elements(&self.root) {
for elem in Self::iter_elements(&self.root) {
// Count wiring: Co elements don't have Type, handle before type check
if elem.name == "Co" {
let in_children: Vec<&Element> = elem
Expand Down
Loading
Loading