feat(form-info): add -Expand parameter for collapsed page drill-down

Pages are collapsed by default showing "(N items)". The new -Expand
parameter allows expanding by name, title, or * for all. A hint line
is shown when collapsed sections exist.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Nick Shirokov
2026-03-15 19:21:51 +03:00
co-authored by Claude Opus 4.6
parent 9cffa81bcc
commit 1479f944f5
3 changed files with 58 additions and 16 deletions
+23 -7
View File
@@ -1,10 +1,11 @@
# form-info v1.0 — Analyze 1C managed form structure
# form-info v1.1 — Analyze 1C managed form structure
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
param(
[Parameter(Mandatory=$true)]
[string]$FormPath,
[int]$Limit = 150,
[int]$Offset = 0
[int]$Offset = 0,
[string]$Expand
)
$ErrorActionPreference = "Stop"
@@ -232,6 +233,7 @@ function Count-SignificantChildren($childItemsNode) {
# --- Build element tree recursively ---
$treeLines = [System.Collections.Generic.List[string]]::new()
$script:hasCollapsed = $false
function Build-Tree($childItemsNode, [string]$prefix, [bool]$isLast) {
if (-not $childItemsNode) { return }
@@ -282,14 +284,21 @@ function Build-Tree($childItemsNode, [string]$prefix, [bool]$isLast) {
$line = "$prefix$connector $tag $name$binding$flags$titleStr$events"
$treeLines.Add($line)
# Recurse into containers (but not Page — show summary)
# Recurse into containers (but not Page — show summary unless expanded)
$localName = $child.LocalName
if ($localName -eq "Page") {
$ci = $child.SelectSingleNode("d:ChildItems", $ns)
$cnt = Count-SignificantChildren $ci
# Append count to last line
$idx = $treeLines.Count - 1
$treeLines[$idx] = $treeLines[$idx] + " ($cnt items)"
$pageName = $child.GetAttribute("name")
$pageTitle = Test-TitleDiffers $child $pageName
$shouldExpand = ($Expand -eq "*") -or ($Expand -eq $pageName) -or ($pageTitle -and $Expand -eq $pageTitle)
if ($shouldExpand -and $ci) {
Build-Tree $ci "$prefix$continuation" $last
} else {
$cnt = Count-SignificantChildren $ci
$idx = $treeLines.Count - 1
$treeLines[$idx] = $treeLines[$idx] + " ($cnt items)"
$script:hasCollapsed = $true
}
} elseif ($localName -in @("UsualGroup", "Pages", "Table", "CommandBar", "ButtonGroup", "Popup")) {
$ci = $child.SelectSingleNode("d:ChildItems", $ns)
if ($ci) {
@@ -540,6 +549,13 @@ if ($isExtension) {
$lines += "BaseForm: $bfStr"
}
# --- Expand hint ---
if ($script:hasCollapsed) {
$lines += ""
$lines += "Hint: use -Expand <name> to expand a collapsed section, -Expand * for all"
}
# --- Truncation protection ---
$totalLines = $lines.Count