mirror of
https://github.com/Nikolay-Shirokov/cc-1c-skills.git
synced 2026-07-17 08:15:16 +03:00
feat(validate): brief output by default, -Detailed for verbose
All 10 validation skills (meta, epf, skd, cf, cfe, form, mxl, role, subsystem, interface) now output a single summary line on success: === Validation OK: Type.Name (N checks) === Errors/warnings always shown. Full per-check [OK] output behind -Detailed flag. Removed all N/A check lines. Unified role-validate output format. Trimmed SKILL.md files from 42-119 to 51-67 lines. Version bumps: meta-validate v1.2, all others v1.1. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
# subsystem-validate v1.0 — Validate 1C subsystem XML structure
|
||||
# subsystem-validate v1.1 — Validate 1C subsystem XML structure
|
||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||
param(
|
||||
[Parameter(Mandatory)][string]$SubsystemPath,
|
||||
[switch]$Detailed,
|
||||
[int]$MaxErrors = 30,
|
||||
[string]$OutFile
|
||||
)
|
||||
@@ -43,10 +44,14 @@ $resolvedPath = (Resolve-Path $SubsystemPath).Path
|
||||
$script:errors = 0
|
||||
$script:warnings = 0
|
||||
$script:stopped = $false
|
||||
$script:okCount = 0
|
||||
$script:output = New-Object System.Text.StringBuilder 8192
|
||||
|
||||
function Out-Line([string]$msg) { $script:output.AppendLine($msg) | Out-Null }
|
||||
function Report-OK([string]$msg) { Out-Line "[OK] $msg" }
|
||||
function Report-OK([string]$msg) {
|
||||
$script:okCount++
|
||||
if ($Detailed) { Out-Line "[OK] $msg" }
|
||||
}
|
||||
function Report-Error([string]$msg) {
|
||||
$script:errors++
|
||||
Out-Line "[ERROR] $msg"
|
||||
@@ -120,8 +125,6 @@ if (-not $script:stopped) {
|
||||
# --- 3. Name ---
|
||||
$nameEl = $props.SelectSingleNode("md:Name", $ns)
|
||||
$subName = if ($nameEl) { $nameEl.InnerText.Trim() } else { "" }
|
||||
Out-Line ""
|
||||
Out-Line "=== Validation: Subsystem.$subName ==="
|
||||
# Re-insert header at position 0
|
||||
$headerLine = "=== Validation: Subsystem.$subName ==="
|
||||
$script:output.Insert(0, "$headerLine`r`n`r`n") | Out-Null
|
||||
@@ -256,8 +259,6 @@ if (-not $script:stopped) {
|
||||
} else {
|
||||
Report-Warn "10. ChildObjects files: missing: $($missingFiles -join ', ')"
|
||||
}
|
||||
} else {
|
||||
Report-OK "10. ChildObjects files: n/a (no children)"
|
||||
}
|
||||
|
||||
# --- 11. CommandInterface.xml ---
|
||||
@@ -307,10 +308,16 @@ if (-not $script:stopped) {
|
||||
}
|
||||
|
||||
# --- Finalize ---
|
||||
Out-Line "---"
|
||||
Out-Line "Errors: $($script:errors), Warnings: $($script:warnings)"
|
||||
$checks = $script:okCount + $script:errors + $script:warnings
|
||||
|
||||
if ($script:errors -eq 0 -and $script:warnings -eq 0 -and -not $Detailed) {
|
||||
$result = "=== Validation OK: Subsystem.$subName ($checks checks) ==="
|
||||
} else {
|
||||
Out-Line ""
|
||||
Out-Line "=== Result: $($script:errors) errors, $($script:warnings) warnings ($checks checks) ==="
|
||||
$result = $script:output.ToString()
|
||||
}
|
||||
|
||||
$result = $script:output.ToString()
|
||||
Write-Host $result
|
||||
|
||||
if ($OutFile) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env python3
|
||||
# subsystem-validate v1.0 — Validate 1C subsystem XML structure
|
||||
# subsystem-validate v1.1 — Validate 1C subsystem XML structure
|
||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||
"""Validates subsystem XML file structure, properties, content items, child objects."""
|
||||
import sys, os, argparse, re
|
||||
@@ -22,18 +22,22 @@ IDENT_PATTERN = re.compile(
|
||||
|
||||
|
||||
class Reporter:
|
||||
def __init__(self, max_errors):
|
||||
def __init__(self, max_errors, detailed=False):
|
||||
self.errors = 0
|
||||
self.warnings = 0
|
||||
self.ok_count = 0
|
||||
self.stopped = False
|
||||
self.max_errors = max_errors
|
||||
self.detailed = detailed
|
||||
self.lines = []
|
||||
|
||||
def out(self, msg=''):
|
||||
self.lines.append(msg)
|
||||
|
||||
def ok(self, msg):
|
||||
self.lines.append(f'[OK] {msg}')
|
||||
self.ok_count += 1
|
||||
if self.detailed:
|
||||
self.lines.append(f'[OK] {msg}')
|
||||
|
||||
def error(self, msg):
|
||||
self.errors += 1
|
||||
@@ -67,11 +71,13 @@ def main():
|
||||
description='Validate 1C subsystem XML structure', allow_abbrev=False
|
||||
)
|
||||
parser.add_argument('-SubsystemPath', dest='SubsystemPath', required=True)
|
||||
parser.add_argument('-Detailed', action='store_true')
|
||||
parser.add_argument('-MaxErrors', dest='MaxErrors', type=int, default=30)
|
||||
parser.add_argument('-OutFile', dest='OutFile', default='')
|
||||
args = parser.parse_args()
|
||||
|
||||
subsystem_path = args.SubsystemPath
|
||||
detailed = args.Detailed
|
||||
max_errors = args.MaxErrors
|
||||
out_file = args.OutFile
|
||||
|
||||
@@ -105,7 +111,7 @@ def main():
|
||||
sys.exit(1)
|
||||
|
||||
resolved_path = os.path.abspath(subsystem_path)
|
||||
r = Reporter(max_errors)
|
||||
r = Reporter(max_errors, detailed)
|
||||
|
||||
# --- 1. XML well-formedness + root structure ---
|
||||
xml_doc = None
|
||||
@@ -240,8 +246,6 @@ def main():
|
||||
r.warn(f'7. Content: duplicates found: {", ".join(dupes)}')
|
||||
else:
|
||||
r.ok('7. Content: no duplicates')
|
||||
else:
|
||||
r.ok('7. Content: no duplicates (empty)')
|
||||
|
||||
# --- 8. ChildObjects entries non-empty ---
|
||||
child_objs = sub.find('md:ChildObjects', NS)
|
||||
@@ -272,8 +276,6 @@ def main():
|
||||
r.error(f'9. ChildObjects: duplicates: {", ".join(dupes)}')
|
||||
else:
|
||||
r.ok('9. ChildObjects: no duplicates')
|
||||
else:
|
||||
r.ok('9. ChildObjects: no duplicates (empty)')
|
||||
|
||||
# --- 10. ChildObjects files exist ---
|
||||
if len(child_names) > 0:
|
||||
@@ -289,8 +291,6 @@ def main():
|
||||
r.ok(f'10. ChildObjects files: all {len(child_names)} files exist')
|
||||
else:
|
||||
r.warn(f'10. ChildObjects files: missing: {", ".join(missing_files)}')
|
||||
else:
|
||||
r.ok('10. ChildObjects files: n/a (no children)')
|
||||
|
||||
# --- 11. CommandInterface.xml ---
|
||||
parent_dir2 = os.path.dirname(resolved_path)
|
||||
@@ -331,10 +331,14 @@ def main():
|
||||
r.ok('13. UseOneCommand: false (no constraint)')
|
||||
|
||||
# --- Finalize ---
|
||||
r.out('---')
|
||||
r.out(f'Errors: {r.errors}, Warnings: {r.warnings}')
|
||||
checks = r.ok_count + r.errors + r.warnings
|
||||
if r.errors == 0 and r.warnings == 0 and not detailed:
|
||||
result = f'=== Validation OK: Subsystem.{sub_name} ({checks} checks) ==='
|
||||
else:
|
||||
r.out('')
|
||||
r.out(f'=== Result: {r.errors} errors, {r.warnings} warnings ({checks} checks) ===')
|
||||
result = '\r\n'.join(r.lines) + '\r\n'
|
||||
|
||||
result = r.text()
|
||||
print(result, end='')
|
||||
|
||||
if out_file:
|
||||
|
||||
Reference in New Issue
Block a user