CLI command design

pcblib

Authors PCB footprint libraries through generated MCO operations.

Purpose

pcblib provides small public authoring workflows for Altium .PcbLib files. The command is intentionally a wrapper over MCO rather than a separate writer path, so future footprint operations such as pad, text, body, and model insertion can reuse the same document-session and reporting behavior.

Usage

altium-cruncher pcblib create footprints/test_fixture.PcbLib
altium-cruncher pcblib create footprints/test_fixture.PcbLib --footprint DBG_CONTACT_FP --force
altium-cruncher pcblib create fixture.PcbLib --parameter AREA=1mil^2 --primitive-parameter Value=TP1
altium-cruncher pcblib create fixture.PcbLib --emit-mco fixture.mco.json --json

Arguments

ArgumentContract
create fileDestination .PcbLib. The output path is passed into the generated MCO as file.
--footprintInitial footprint pattern name. If omitted, the output filename stem is used.
--height, --descriptionInitial footprint metadata written through the standard PcbLib Parameters stream.
--parameter NAME=VALUEAdditional standard footprint Parameters entries. May be repeated.
--primitive-parameter NAME=VALUEFootprint-level PrimitiveParameters side-stream entries. May be repeated.
--emit-mcoWrites the generated MCO JSON before execution so the exact operation sequence can be inspected or replayed with mco run.
--force, --dry-run, --json, --json-outputFollow the existing MCO command semantics for overwrite, non-mutating planning, stdout JSON, and sidecar JSON report output.

MCO Shape

pcblib create compiles to pcblib.create followed by pcblib.add_footprint. pcblib.create initializes a new PcbLib document session, and pcblib.add_footprint performs the first saveable mutation. This keeps library creation decomposed enough for later primitive-level footprint MCO operators.

Output

The command writes the requested .PcbLib file unless --dry-run is used. Human output is the standard MCO execution summary. --json writes the execution report to stdout, --json-output writes the same report to a file, and --emit-mco writes the generated operation payload before execution.

Tests

Coverage lives in tests/test_mco.py and tests/test_pcblib_command.py. It verifies the PcbLib MCO operators, generated operation catalog entries, CLI MCO emission, execution reporting, and generated library reparse including footprint metadata and PrimitiveParameters.